BTW, this looks like a copy & paste of some code from perlre.
When you add a use re 'debug'; to your code (or use re Debug => 'EXECUTE';), it outputs this:
Matching REx "(.*?)(\d*)" against "I have 2 numbers: 53147" 0 <> <I have 2 n> | 0| 1:OPEN1(3) 0 <> <I have 2 n> | 0| 3:MINMOD(4) 0 <> <I have 2 n> | 0| 4:STAR(6) 0 <> <I have 2 n> | 1| 6:CLOSE1(8) 0 <> <I have 2 n> | 1| 8:OPEN2(10) 0 <> <I have 2 n> | 1| 10:STAR(12) | 1| POSIXU[\d] can match 0 times out +of 2147483647... 0 <> <I have 2 n> | 2| 12:CLOSE2(14) 0 <> <I have 2 n> | 2| 14:END(0) Match successful! (.*?)(\d*) <> <>
Since the non-greedy modifier ? causes .* to match the minimum number of times possible, which is zero, followed by zero or more digits (\d*), the regex succeeds having matched zero characters.
In reply to Re: Regex Minimal Quantifiers
by haukex
in thread Regex Minimal Quantifiers
by pr33
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |