Perl: the Markov chain saw | |
PerlMonks |
Re: Mind boggling regexby davis (Vicar) |
on Oct 26, 2001 at 18:08 UTC ( [id://121631]=note: print w/replies, xml ) | Need Help?? |
The problem lies in that you're assuming that the \1 is going to contain the contents of the first set of parentheses. It won't. In a character class, metacharacters etc take on a different meaning. I believe in this case the second set of parantheses is attempting to match 'any character that doesn't have octal code 001' Remember, metacharacters take on a different meaning inside character classes. I'm just off now to see if I can figure out an elegant solution to this one. Update: 4 seconds later -- as ever, others have answered before me. japhy's solution is classier than I can attempt /me wonders off to look up lookahead assertions properly.
In Section
Seekers of Perl Wisdom
|
|