11 ms·
On the main issue of your regexp being wrong: You can feed your regexp into any engine and see it will happy match "\" which it should not. As for the is
by morelisp 6y ago
On the main issue of your regexp being wrong: You can feed your regexp into any engine and see it will happy match
"\"
which it should not.
As for the issue of varying between engines: The classic deviation between POSIX and non-POSIX regexp is whether you pick leftmost-longest and tiebreak by alternate order, or leftmost first alternate. (POSIX is the correct answer because there are benefits to commutative alternation.) Non-greedy regexp has a similar issue for whether it should prefer shortest or first alternate. (Proper thinking about regexes doesn't involve temporal relations like "before" or "thus far" or whether something is "consumed" - even in engines that don't implement leftmost-longest this can only confuse.)
Engines that take alternation order into account will also have it match the complete string of:
"\""
Probably to the confusion of anyone who read that non-greedy operators will choose the shortest match.
tl;dr: Don't use non-greedy operators. Don't think about regular language matching in temporal or procedural terms. Don't try to rewrite regexps without test cases.