in reply to Re^3: Regular Expressions
in thread Regular Expressions
What I find interesting is that for the first case perl doesn't warn about it at all*. If I have a regex that uses backreferences but has no capturing parens, I'd expect that perl (with use warnings enabled) would mention something about it.
I'm not saying it's wrong behavior, and I understand why it's not matching. It just didn't provide the warning I'd expect.
*update: Or put it another way. I mean that the error message "Reference to nonexistent group in regex;" goes away if the regex is changed slightly. Consider:
print "matches\n" if $test_string =~ /(?:f)\1(.)/;
There is a valid set of capturing parens there, but after the \1 backreference is used. So this won't match -- and Perl doesn't warn about it. Surprised me a bit.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Regular Expressions
by chas (Priest) on May 17, 2005 at 22:20 UTC |