Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Answer: How do I find $a only where it's not followed by $b and then replace it with $c?

( #3496=categorized answer: print w/ replies, xml ) Need Help??

Q&A > regular expressions > How do I find $a only where it's not followed by $b and then replace it with $c? contributed by neshura

Use Perl's cool "zero-width negative lookahead assertion".

s/$a(?!$b)/$c/;

Comment on Answer: How do I find $a only where it's not followed by $b and then replace it with $c?
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2014-08-21 16:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (138 votes), past polls