RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
(NOT)?(\s*\(*)\s*(\w+)\s*(=|<>|<|>|LIKE|IN)\s*(\(([^\)]*)\)|'([^']*)'|(-?\d*\.?\d+))(\s*\)*\s*)(AND|OR)?
Description
Heres my sql clause parser regexp for recordset filtering. Does recursive query parsing all by its self. Only problem I cant figure is how to match comma separated lists of quoted strings. Tell me if you figure out how! The unicodes in the re was put in by the entry form please replace them with their ascii equivalents to use it.
Matches
Aeroplane LIKE 767 | Movie LIKE 'Star' AND NOT Movie LIKE 'Trek' | Number IN (1,2,3,4,5)
Non-Matches
Hello there | A=EXCELLENT OR | B!=POOR
Author Rating: Not yet rated. Joseph Warwick
Source
Your Rating
Bad Good

Enter New Comment

Title
 
Name
 
Comment
 
Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Title: begin and end blocks
Name: Joseph Warwick
Date: 9/12/2005 7:45:07 AM
Comment:
You capture from beginning to end of a text string you can use ^(^$)*


Title: Goes well
Name: V.C.Sekhar
Date: 10/16/2004 12:37:48 AM
Comment:
Hi Joseph, your expression worked fine with my stored procs. Nice to see this. I am in the making of a regular-expression based T-SQL parser. Just to check with you whether I can request some info from you regarding few expressions. I tried to capture the text between begin and end blocks using ^begin(.\n)*end$ , but failed miserably. Thanks in advance, Sekhar vcsekhar007 at yahoo.com


Title: Comma Separated Quoted Lists
Name: Dave W
Date: 12/11/2003 5:17:06 PM
Comment:
Does this do the job in terms of matching a single quoted string spearated commas(".*?",)


Title: More details
Name: James F.
Date: 10/8/2003 6:59:07 PM
Comment:
I don't have excellent knowledge of SQL queries, but what charaters are allowed within quotes (if they are to be restricted)? Anyway, you would replace your sub-mask: |'([^']*)'| by this one: |('([^']*)')(,\s*'([^']*)')*|


Copyright © 2001-2018, RegexAdvice.com | ASP.NET Tutorials