Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

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

by neshura (Chaplain)
on Feb 15, 2000 at 03:19 UTC ( #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? - Answer 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?
[Corion]: Their older sister just started piano but has been interested in drumming, which she should be able to start with 8 years or so)
[Discipulus]: ah was Kink of Bongo 1992..
[1nickt]: choroba name of band? youtube link? MySpace link?
[Your Mother]: I like Manu Chao.
[Your Mother]: I like this one quite well, https://www. youtube.com/watch? v=rSEUH4KRfN8
[choroba]: Půlnoční Marie (which means Midnight Mary)
[choroba]: but the band is practically dead. We rehearse once in a year, and perform with the same frequency
[ambrus]: `quote
[ambrus]: sorry, typed in the wrong box
[LanX]: Your mother: je ne t'aime plus! ;)

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (11)
As of 2017-03-24 12:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (301 votes). Check out past polls.