Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^3: is (?: ... ) capturing

by ysth (Canon)
on Sep 07, 2009 at 07:47 UTC ( #793897=note: print w/ replies, xml ) Need Help??


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


Comment on Re^3: is (?: ... ) capturing
Download Code
Re^4: is (?: ... ) capturing
by jeanluca (Deacon) on Sep 07, 2009 at 07:51 UTC
    ok, thnx again!!
Re^4: is (?: ... ) capturing
by ikegami (Pope) 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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://793897]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (9)
As of 2015-07-07 07:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (87 votes), past polls