07-09-2013 07:40 AM
I'm having some trouble with "Match by Regular Expression"- I was thinking some of you guys are really quick with this stuff and it might be easy for you to enlighten me for some kudos.
The current regex I'm trying to match is: "([^"]*)",?
I beleive this says to match the longest string in quotes not containing any quotes- am I correct? (I'm not the author of this original exp).
the comma-question-mark means there may be one or more ccommas after the string found?
Here's what I'm urrently causing errors trying to add - I need it to match the above regular expression OR a null string. I though adding a pipe at the end might do it but it still caused the match to report "-1" on the offset past match.
Anyone have any ideas?
Thanks and kudos to any help!
-pat
Solved! Go to Solution.
07-09-2013 10:44 AM
Have not tried to capture a null before but to me it sounds a lot like a blank line.
You might try a pipe with line anchors (I.E., |^$)
07-09-2013 12:30 PM - edited 07-09-2013 12:59 PM
unfortunetly that didnt seem to work- thanks for the idea though!
EDIT: I also tried throwing ( )? around the original regexp... still didnt work
EDIT#2: correction the ( )? works but it then does not work with the original expression where it should match the content in quotes...
07-09-2013 01:22 PM
The '?' matches 0 or 1 occurrences of the character or grouping that precedes it. For 1 or more commas, you want +.
I think Don has the right idea. See if ("([^"]*)",?)|(^$) works for you. If not, can you post a sample string, and the expected output?
07-09-2013 01:41 PM
Yes! that is it, I forgot the parenthases! it works.
Kudos all'round
thanks again
-Pat