I have a text file which contains strings with prefix A_B_.
Example: A_B_Monday
I would like to replace all occurences of A_B_* with X_Y_* except when * is C.
So all strings that are A_B_* but not A_B_C must be replaced by X_Y_*.
How should this be done in perl?
Edit:1
The * above is a string. So all A_B_* that are not A_B_Geneva should be replaced with X_Y_NewYork.
perl -pi.bak -e ‘s/^A_B_(!Geneva)/X_Y_/g;’ File.Txt does not seem to work. I am on Strawberry Perl.
Update:
This worked for me
perl -i.bak -pE “s/A_B_(?!Geneva)/USB_EP_/g” File.Txt
Maybe:
or: