For the common problem of matching text between delimiters (e.g. < and >), there’s two common patterns:
- using the greedy
*or+quantifier in the formSTART [^END]* END, e.g.<[^>]*>, or - using the lazy
*?or+?quantifier in the formSTART .*? END, e.g.<.*?>.
Is there a particular reason to favour one over the other?
Some advantages:
[^>]*:/sflag.[^>]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.