I have a string which have & like the one below.
"This R&M & Exapmle . It is very big & Complicated &146; example."
I wants to replace &
with &
but when I use $str =~ s/&/&/ig;
which give the following output.
"This R&M & Company  . It is very big & CMM Level3 &146; Organization."
And I am expecting this one.
"This R&M & Company . It is very big & CMM Level3 &146; Organization."
Please help me I don't have any idea how to fix it.
You can use a negative look-ahead assertion:
$str =~ s/&(?!\w+;)/&/g;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With