I am trying to replace a + character into a hyphen I have in my string.
+
hyphen
String str = \"word+word\"; str.replaceAll(\'+ \', \'-\');
If you are not sure about the escape sequence you need to use,
You could simply do this.
str = str.replaceAll(Pattern.quote("+"), "-");
This will automatically escape the regex predefined tokens to match in a literal way