http://qs321.pair.com?node_id=390141


in reply to Re^4: On zero-width negative lookahead assertions
in thread On zero-width negative lookahead assertions

To make it behave as you describe, use (?>\s*). The (?> ) says whatever is in it will match whatever it would match at that point in the string as an independent expression. So if matching all the spaces makes something later on fail, it won't backtrack and try having the \s* match fewer spaces.

(It's really time to unmark all of the extensions as experimental, except perhaps how variables in (?{}) and (??{}) bind.)

  • Comment on Re^5: On zero-width negative lookahead assertions