For the common problem of matching text between delimiters (e.g. <
and >
), there\'s two common patterns:
*>
Some advantages:
[^>]*
:
/s
flag.[^>]
the engine doesn't make choices - we give it only one way to match the pattern against the string)..*?
(?:(?!END).)*
. This is even worse if the END delimiter is another pattern.