in reply to Search and replace logic
Or the perhaps simpler to understand:s/(nce|nse)/${{nce=>nse=>nse=>nce=>}}{$1}/g
I see you have //i. If you want to preserve equivalent case in the replacements, you'll have to specify all the different combinations of case in the hash, or use s/(whatever)/mangle("$1")/ie where mangle is a sub that does whatever transformation you want.%repl = (nce => 'nse', nse => 'nce'); foreach (...) { s/(nce|nse)/$repl{$1}/g; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Search and replace logic
by freddo411 (Chaplain) on Nov 19, 2003 at 17:22 UTC |