|
|
Browse by Tags
All Tags » .NET » sql query
-
Hello,
I've been trying to write a regex that would split any sql select query and capture different clauses to the groups. That is, there should be 5 groups (eg. top, select, from, where, order) each containing corresponding text (the group is empty if the clause is missing).
For example, lets try and split this query:
SELECT ...
-
Here you go:
(?i)^\[[^\]]+\]\.\[[^\]]+\]\s+(?:LIKE|=|<|>|<>|<=|>=)\s+(?:'[^']*'|\d+)(?:\s+AND\s+\[[^\]]+\]\.\[[^\]]+\]\s+(?:LIKE|=|<|>|<>|<=|>=)\s+(?:'[^']*'|\d+))?\s*$
|
|
|