in reply to Re: regexp: non-capturing grouping in replacement possible?
in thread regexp: non-capturing grouping in replacement possible?

I forgot to mention that I tried it but either I am doing something wrong or ...:
$str =~ s/(?=hello kitty )(\d+)/sprintf "%d", $1/e;
does not do anything. it is probably me but I don't see it.

Replies are listed 'Best First'.
Re^3: regexp: non-capturing grouping in replacement possible?
by happy.barney (Friar) on Nov 26, 2009 at 13:27 UTC
    ?= is look ahead. try ?<= (look behind)
      That's right. The regex engine walks the string from left to right, so looking left of a pattern is a look-behind, looking right of a pattern is a look-ahead.
      thanks :). working great. $str =~ s/^(?<=hello kitty )(\d\d*)(?=x\d+.*)/sprintf "%d", $1/e;;