For the common problem of matching text between delimiters (e.g. <
and >
), there\'s two common patterns:
*>
The first is more explicit, i. e. it definitely excludes the closing delimiter from being part of the matched text. This is not guaranteed in the second case (if the regular expression is extended to match more than just this tag).
Example: If you try to match
with <.*?>Hello!
, the regex will match
Hello!
whereas <[^>]*>Hello!
will match
Hello!