How to get substring " It's big \"problem " using a regexp
s = ' function(){ return " Is big \"problem "; }';
How to get substring " It's big \"problem " using a regexp
s = ' function(){ return " Is big \"problem "; }';
Friedl's classic "unrolled-loop" pattern:
/"[^"\\]*(?:\\.[^"\\]*)*/
One has to remember that regexps aren't a silver bullet for everything string-y. Some stuff are simpler to do with a cursor and linear, manual, seeking. A CFL would do the trick pretty trivially, but there aren't many CFL implementations (afaik).
/"(?:[^"\\]|\\.)*"/
Works in The Regex Coach and PCRE Workbench.
Example of test in JavaScript:
var s = ' function(){ return " Is big \\"problem\\", \\no? "; }';
var m = s.match(/"(?:[^"\\]|\\.)*"/);
if (m != null)
alert(m);