This is my first post. I have problem with String in Java. I want to use regular expression. Thank you in advance for any help.
My String is:
String str = "abXYxyzXYZabXasdfggXYZ".
I want to replace all characters with "+" but not variable below:
String word = "XYZ"
So the output should be like that:
+++++++XYZ+++++++++XYZ.
I started out with:
str.replaceAll("[^" + word + "]", "+")
But I got different output like that:
++XY+++XYZ++X++++++XYZ