![]() |
|
There's more than one way to do things | |
PerlMonks |
Re: Regex: Case insensitive search but case sensitive replaceby ehdonhon (Curate) |
on Nov 17, 2003 at 11:54 UTC ( #307631=note: print w/replies, xml ) | Need Help?? |
If you use the /i switch in combination with 's///', it will capture any case permutation of whatever it is you are replacing, and if you use that captured text, it will appear in the exact same case permutation as it was captured. This will work no matter what you are trying to capture.
Output: Hello, my name is "FRED"! "fREd" went to the store. Nobody was home, except for "freD". You mention in a later post that you are looking for something more generic that will work for anything, not just names. Perhaps this is what you are looking for?
Output: - John is following ##jane## - John is following ##Jane##
In Section
Seekers of Perl Wisdom
|
|