"be consistent" | |
PerlMonks |
Regex question is this one of those look (ahead|behind)s ?by misterperl (Pilgrim) |
on Mar 25, 2014 at 17:36 UTC ( [id://1079709]=perlquestion: print w/replies, xml ) | Need Help?? |
misterperl has asked for the wisdom of the Perl Monks concerning the following question:
$_ = 'abcdef'; 1. replace def with xyz if the string DOESNT have a preceding a: s/^(\SB^aSB*)def/$1xyz/ works fine. (note SB = SQUARE BRACKET, this EDITOR is removing them for some reason) But let's say instead, only replace if the preceeding string is NOT eq 'abc' exactly? I studied NLB Assertion and thought this would bring joy: s/^(?<!abc)def/$1xyz/ but no joy. It never substitutes now if preceeded by abc or NOT preceeded by it.. Wisdom is appreciated.
Back to
Seekers of Perl Wisdom
|
|