The regular expression is:
(?i)IS_HOLIDAY\('(.*?)'(?:(?:,\s*'((?:\s*\w+)+)')*)\)
I try to parse :
IS_HOLIDAY('10/01/2009','CAD', 'us holiday', 'test')
and I want to get
Group 1 : 10/01/2009
Group 2 : CAD
Group 3 : us holiday
Group 4 : test
however I got
Group 1 : 10/01/2009
Group 2 : test
How to modify upper expression, any suggestion? thanks
The second big subexpression doesn't account for multiple arguments.
You can't get a varying number of matches back. I'd grab what's in the parentheses and then do a match on that for anything that looks like an argument.
What language are you using?
The second big subexpression doesn't account for multiple arguments.
You can't get a varying number of matches back. I'd grab what's in the parentheses and then do a match on that for anything that looks like an argument.
What language are you using?
I use JAVA.
I could use Expression like : (?i)IS_HOLIDAY\('(.*?)'((?:,\s*'(?:\s*\w+)+')*)\)
So The Group 2 I will get like : ,'CAD', 'us holiday', 'test', then parse it using JAVA.
But this way looks not that good.
Actually, I lie. Try this.
(?<=IS_HOLIDAY\(|,)\s*('(?:\\.|[^'])*'|"(?:\\.|[^"])*"|[^'",)]+)
Match that against the entire string and grab the [1]s.
Thanks for your prompt reply. but I am really confused, is that match upper sentence (IS_HOLIDAY('10/01/2009','CAD', 'us holiday', 'test'))? could you explain a little.
Yes. Run that expression against the entire string (assuming the string is exactly what you say it is).
I test it using The Regex Coach, looks like it doesn't work.
I use (?i)IS_HOLIDAY\('([^']*)','((?:[^',]+|'|,)*)'\) to check the sentence, and using '\s*,\s*' to split the group(2). any way, it is working.
Thanks again.
I might have missed something here; are you wanting to match everything between the single quotation marks?