in reply to Re: is (?: ... ) capturing
in thread is (?: ... ) capturing

thnx a lot!!
I'm using 5.6, so if I had to do something like
my $str = "abc def 123 456" ; $str =~ s/(?:\s+)\w/_/g ;
I would have had to do it differently, correct ? cheers

Replies are listed 'Best First'.
Re^3: is (?: ... ) capturing
by ysth (Canon) on Sep 07, 2009 at 07:47 UTC
      s/(\s+)\w/${1}_/g
      simplifies to
      s/(\s)\w/${1}_/g
      Now you can use a zero-width lookbehind to get the speed boost of avoiding captures.
      s/(?<=\s)\w/_/g
      Or in 5.10+:
      s/\s\K\w/_/g
      ok, thnx again!!