-
1. Re: Extract code lines with RegExp
birnerseff Jan 29, 2012 6:48 AM (in response to Peter Celuch)Hi,
the regex should be /(.*?;)\s*\n/s
Note the "s" for "span lines" or "dotall"
-
2. Re: Extract code lines with RegExp
Peter Celuch Jan 29, 2012 7:49 AM (in response to birnerseff)Thank you very much! I totaly missed "s" parameter. However, it's still not exactly what I need.
I added "g" flag so it runs through all occurences, put ";" out of parenthesis so it's not included in result string and added \s* before parenthesis to trim any indenting.
var pattern:RegExp = /\s*(.*?);\s*\n/gs;
One last problem is, that if I have semicolon in line, let's say
trace("this is semicolon: ';'");Is there a way to say to regex "If semicolon is between quotes, don't count it as semicolon", or even better, if quotes are escaped \", don't count them as quotes
So it could chew up event string like:
trace("this is semicolon: \";\""); -
3. Re: Extract code lines with RegExp
birnerseff Jan 29, 2012 8:29 AM (in response to Peter Celuch)Hi,
it might work to replace dot (any character) by ("[^"]*"|'[^']*'|[^;])
This would handle simple quoted strings but no escaped quotes.
You could then try to replace [^"] (all but quote) by (\\.|[^"]) ... make sure to get the proper number of backslashes
-
4. Re: Extract code lines with RegExp
Peter Celuch Jan 29, 2012 8:39 AM (in response to birnerseff)Works like a charm.
Thanks a lot!


