s/\b(find)\b/ uc('repl') | ( $1 ^ uc($1) ) /eig;
Only guaranteed to work for search strings and replacement strings consisting entirely of ASCII letters. Non-letter and accented characters won't work. EBCDIC won't work. It also only works if $1 and $find are the same length.
Update: Added clarification (by adding "guaranteed") and an extra failure mode.
In reply to Re: Respect case in substitution
by ikegami
in thread Respect case in substitution
by b4swine
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |