"Jeff 'japhy/Marillion' Pinyan" <jeffp@crusoe.net> wrote: :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. If you change the lookbehind to this: (?<= (?{ print "<$`><$&><$'>" }) .. ) you get: <><ja><phy> <><japh><y> <><><japhy> <><ja><phy> .. which makes slightly more sense. We don't currently sign any contract to guarantee the value of $& and friends inside a regexp. I'm not convinced that we ought to - if you choose to document this, I'd strongly recommend a warning that it may change in the future. HugoThread Previous | Thread Next