johnrcomeau has asked for the wisdom of the Perl Monks concerning the following question:
Only the 3rd regular expression shows as true. I don't understand why the '4' is not matching the (?=4) pattern or (?=\d) pattern in the first two tests. Regards, Johnmy $string = '54W'; if ($string =~ /(?=4)W/x) { warn "1 true\n"; } if ($string =~ /(?=\d)W/x) { warn "2 true\n"; } if ($string =~ /\dW/x) { warn "3 true\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: zero-width assertions for extended regular expressions
by smls (Friar) on May 26, 2014 at 19:10 UTC | |
by Laurent_R (Canon) on May 26, 2014 at 21:14 UTC | |
|
Re: zero-width assertions for extended regular expressions
by AnomalousMonk (Archbishop) on May 26, 2014 at 22:50 UTC | |
by Anonymous Monk on May 27, 2014 at 07:41 UTC |