in reply to replace a character based on rule file
If I understand your task description correctly, I think you just need a basic regex substitution:
The (?<=na) part there is called a "positive look-back assertion" - check that out on perlre. It says that any "m" will be replaced by "+d" if it's preceded by "na".while(<>) { s/(?<=na)m/+d/g; print; }
|
|---|