in reply to How to modify my regex?
So simply:
With the ? qualifier, the regex engine is no longer going to match as much as possible, i.e. up to the very last occurrence of the MARKERS#} end delimiter, but will be happy to stop at the first one, which is what you need here. Actually, when quantifying . any character symbol, the .* or the .+ pattern is relatively rarely what you want, quite often .*? and .+? are better. But that's not a general rule, there also cases when you want to match up to the end of the last regex end delimiter.my $regex = '%17\{#MARKERS.*?MARKERS#}';
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to modify my regex?
by OldChamp (Acolyte) on Aug 26, 2015 at 20:57 UTC |