Consider this regex: <(.*)>
Applied against this string:
<2356> <my pal ned> <!@%@>
Obviously, it will match the entire string because of the greedy *
. The best solution would be to use a non-greedy quantifier, like *?
. However, many languages and editors don't support these.
For simple cases like the above, I've gotten around this limitation with a regex like this: <([^>]*)>
But what could be done with a regex like this? start (.*) end
Applied against this string:
start 2356 end start my pal ned end start !@%@ end
Is there any recourse at all?