[X] $regexp non-greedy fails

$regexp(axxxz,x.*?z,) give a rather than axx as documented:

Non-greedy repeats
Non-greedy repeats are possible by appending a '?' after the repeat; a non-greedy repeat is one which will match the shortest possible string.

You have to keep in mind that regular expressions are evaluated from left to right.

Considering your example, the engine starts at a

  1. a does not match against the pattern
  2. x does match partially and gets consumed
  3. x does match partially and gets consumed
  4. x matches because it is followed by a z and both get consumed.

Not a bug in the regexp engine.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.