http://www.perlmonks.org?node_id=793897


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

Yes, because lookbehind has to be fixed-width, you'd need to do s/(\s+)\w/${1}_/g.
--
A math joke: r = | |csc(θ)|+|sec(θ)|-||csc(θ)|-|sec(θ)|| |
Online Fortune Cookie Search
Office Space merchandise

Replies are listed 'Best First'.
Re^4: is (?: ... ) capturing
by ikegami (Patriarch) on Sep 07, 2009 at 09:30 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
Re^4: is (?: ... ) capturing
by jeanluca (Deacon) on Sep 07, 2009 at 07:51 UTC
    ok, thnx again!!