I need to replace all "&
" symbols with "&
" in my text file but not the html codes such as &
or "
I'm currently using row = row.replace("& ", "&");
but, as I said also the html codes are replaced e.g. "
and I don't want this..
thanks
ps. I cannot add spaces after & because I need to replace it in words such as M&M
or Ella & David
You could try a regex, e.g,
row = row.replaceAll("&(?![#a-zA-Z0-9]+;)", "&");
The regex replace &
given that it's not followed by a sequence of '#a-zA-Z0-9' ending with ';'
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