This is forwarded from a conversation I had with Jeff Friedl. ========================================================================== Jeff 'japhy/Marillion' Pinyan <jeffp@crusoe.net> wrote: |> The only problem is (understandable) that $&, while updated in a |> look-ahead, is NOT "down"dated in a look-behind: |> |> "japhy" =~ m{ |> .. |> (?{ print "<$`><$&><$'>" }) |> (?= |> .. |> (?{ print "<$`><$&><$'>" }) |> ) |> (?<= |> .. |> (?{ print "<$`><$&><$'>" }) |> ) |> (?{ print "<$`><$&><$'>" }) |> }x; |> |> The output is: |> |> <><ja><phy> |> <><japh><y> |> <><ja><phy> |> <><ja><phy> The 2nd one looks like a bug to me. The lookahead is just that, lookahead, and so I feel that it should never (ever) be part of $&. The other ones seem as I would expect them. ========================================================================== I said it didn't seem like a bug, because: 1. look-ahead is a regex, and the modifications done to $& are localized 2. if $& wasn't touched, there'd be little to no information you could get out of it, apart from capturing (which then bumps up your following captures) 3. look-behind isn't much of a "regex", and so I don't think it gets treated the same way internally What's it seem like to you? -- Jeff "japhy" Pinyan japhy@pobox.com http://www.pobox.com/~japhy/ I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun. Are you a Monk? http://www.perlmonks.com/ http://forums.perlguru.com/ Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/ Acacia Fraternity, Rensselaer Chapter. Brother #734 ** Manning Publications, Co, is publishing my Perl Regex book **Thread Next