Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

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

by JadeNB (Chaplain)
on Oct 23, 2008 at 18:47 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2024-04-25 20:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found