Re:Advanced Regular Expression Tips and Techniques
by leeoniya on Monday December 09, 2013 @12:25AM
(#6872928)
i never understood why non-capturing syntax requires extra work - '(?:' vs '(' - seems very backwards.
[ Parent
| on HN ]
Re:Advanced Regular Expression Tips and Techniques
by pcmonk on Monday December 09, 2013 @12:51AM
(#6872990)
I think it's simply because capturing groups are much more common than non-capturing groups. Even though non-capturing is "simpler", it's less common, so we default to capturing and use the more verbose syntax for non-capturing.
Re:Advanced Regular Expression Tips and Techniques
by brudgers on Monday December 09, 2013 @10:39AM
(#6874747)
Consider it as a compiler flag - a regex without capture and backtracking can be represented mathematicly as a regular expression (I.e. it can be translated into a DFA). Once a regex starts capturing, its representation requires a stack or other memory structure. Or a regex might or might not be a regular expression, strictly speaking (which isn't done all that often).