in reply to Regex backreference problem.

It's already explained why this happens, because the character class is created at compile time. But this gives us the right hint to "fix" the regex: use a delayed regex.
($_ = 'aaab') =~ m[(.)((??{"[^$1]"}))] and print "$1|$2"; a|b

Abigail

Replies are listed 'Best First'.
Re: Re: Regex backreference problem.
by BrowserUk (Patriarch) on Oct 10, 2003 at 08:38 UTC

    That works too. The only problem with that was this came up whilst I was trying to tackle your "N-Queens with pure regex" problem. I thought I was onto a more efficient solution, but......it didn't work ;)


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail