in reply to Respect case in substitution
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Respect case in substitution
by graff (Chancellor) on Feb 27, 2008 at 18:33 UTC | |
by ikegami (Patriarch) on Feb 27, 2008 at 20:47 UTC |