#!/usr/bin/perl -wT use strict; # Replace 'See' anywhere in the string $_ = "See spot run. See spot jump."; s/See/MATCH/g; print "'$_'\n"; # 'MATCH spot run. MATCH spot jump.' # Replace 'See' unless lookahead finds the anchor $_ = "See spot run. See spot jump."; s/(?!^)See/MATCH/g; print "'$_'\n"; # 'See spot run. MATCH spot jump.' # Replace 'See' unless lookabehind finds the anchor $_ = "See spot run. See spot jump."; s/(?<!^)See/MATCH/g; # 'See spot run. MATCH spot jump.' print "'$_'\n";
-Blake
In reply to Re: (dooberwah) I'm don't think that gives the same results
by blakem
in thread Regular Expression Tweaking
by dooberwah
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |