b4swine has asked for the wisdom of the Perl Monks concerning the following question:
But this would do the wrong thing if the replacement text contained part of the find text as a substring. As well as would be slow.s/\bfind\b/repl/g; s/\bFIND\b/REPL/g; s/\bFind\b/Repl/g; s/\bfind\b/repl/ig;
Better perhaps would be to write a loop, doing a case insensitive search, followed by a replace. What would be fastest (and most elegant)?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Respect case in substitution
by ysth (Canon) on Feb 27, 2008 at 09:19 UTC | |
|
Re: Respect case in substitution
by moritz (Cardinal) on Feb 27, 2008 at 09:30 UTC | |
|
Re: Respect case in substitution
by ikegami (Patriarch) on Feb 27, 2008 at 10:42 UTC | |
by graff (Chancellor) on Feb 27, 2008 at 18:33 UTC | |
by ikegami (Patriarch) on Feb 27, 2008 at 20:47 UTC |