in reply to Regular Expressions

You are essentially asking Perl to match one or more digits, followed by another single digit that is equal to what it just matched. That means for the overall match to work, it needs to find two consecutive identical digits. The only place you have two equal digits are near the end of your string; '111'. The '$' anchors \1 to the right hand side of the string, so basically the last two 1's are being matched.


Dave

Replies are listed 'Best First'.
Re^2: Regular Expressions
by Anonymous Monk on May 17, 2005 at 20:34 UTC
    (We`re just disscusing this with y8 via IRC...)

    Yes, but ^ anchors \1 to the left hand side. So, the first '3' should be in \1... '\d+' can`t get nothing ...

    Nick <znick at inbox dot ru>