I wanted a regex to match milestone version numbers where the version number could have two or three numbers and an optional milestone suffix. The following test code partially works:
for my $entry (qw(1_0 1_0_1 1_0_beta 1_0_1_beta)) { print "$entry\n" if $entry =~ /^\d+ _\d+ (?> (?:_\d+)? \w+) $/x; }
Prints:
1_0_1 1_0_beta 1_0_1_beta
The 1_0_1 is unexpected (and unwanted). I would have thought the no backtracking section should prevent matching the trailing _1 because (?:_\d+) would match and the backtracking suppression would then cause the \w+ part of the match to fail. What have I misunderstood?
In reply to Unexpected regular expression match by GrandFather
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |