public static final String specialChars1= \"\\\\W\\\\S\"; String str2 = str1.replaceAll(specialChars1, \"\").replace(\" \", \"+\"); public static final String speci
This worked for me:
String result = str.replaceAll("[^\\dA-Za-z ]", "").replaceAll("\\s+", "+");
For this input string:
/-+!@#$%^&())";:[]{}\ |wetyk 678dfgh
It yielded this result:
+wetyk+678dfgh