Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Replace after match in regex (key value subsitution)

by JadeNB (Chaplain)
on Oct 23, 2008 at 18:47 UTC ( #719123=note: print w/replies, xml ) Need Help??


in reply to Replace after match in regex (key value subsitution)

Although others have pointed out that there is a nice one-pass approach to your problem, it is possible to access the location of a match after the match itself:
my $a = 'abc'; $a =~ /(b)/; substr($a, $-[1], $+[1] - $-[1], 'B'); print $a, "\n"; # aBc
See perlvar.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2023-01-29 20:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?