Saturday, January 14, 2012 4:11 PM
I'm searching a regex to filter out the following data
for example the text:
from schema.[table name] d
i want to filter out the from component in 3 groups
1st group = from
2d group = schema.[table name]
3d group = d
the regex that i use (FROM)\s+([\[\]\w\.]+)\s+(AS\s+)?(\b\w+\b) does the trick but can't handle the spaces between the brackets so it only works when there are no spaces
from schema.[tablename] d
How do change this regex expression so the ([\[\]\w\.]+) can also match the schema.[table name]
Sunday, January 15, 2012 11:47 PM
Assuming that the schema is optional, and so are the brackets, you can use something like this:
The pattern above uses non-capturing groups extensively so that the result groups aren't littered with extra captures. Adjust as you see fit.
Off topic: most special characters lose their special meaning in a character class (where it wouldn't make sense). This also apply to the dot, so you can just use "[ab.]" instead of "[ab\.]".
- Marked As Answer by Paul ZhouModerator Monday, January 23, 2012 8:16 AM