|Pathologically Eclectic Rubbish Lister|
look-behind regexby zejames (Hermit)
|on Jul 24, 2002 at 05:27 UTC||Need Help??|
zejames has asked for the
wisdom of the Perl Monks concerning the following question:
Here is my problem : I want to substitute a word, 'foo', by another word 'bar' in a line, but only if that line does not contain 'toto' before matching 'foo'.
Of course, I can do this :
But what I am looking for is an only regex, probably using look-behing assertion. I have played with (?<!pattern), without success. As far as I understand, the problem is that there can be anything between 'toto' and 'foo'.
Any hint ?