Here is a soultion using a /e for the substitution. Lookahead/behind assertions will not work well here so we treat 'input' as the special case of \binput\b that it is. If found we effectively leave it alone by substituting it back in - if not then we sub in OUTPUT.. The result is as desired.
$_= "input and 'input' and 'tinput' and ' input' and 'input ' and inpu +t"; s/('input'|\binput\b)/($1 eq "'input'") ? $1 : "OUTPUT"/eg; print "Got\n$_\n"; print "Want OUTPUT and 'input' and 'tinput' and ' OUTPUT' and 'OUTPUT ' and OUTPUT +";
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
In reply to Re: complex pattern matching
by tachyon
in thread complex pattern matching
by christopherbarsuk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |