This is the code for example
String a="abcd ABCD 0123 !@#$%^&*()";
This is syntax for replacing numbers & alphabets with blank
a = a.replaceAll("[a-zA-Z0-9]","");
This is syntax for replacing special characters with blank
a = a.replaceAll("[^\\w\\s-_]","");
So how do I combine both of these syntax to replace special characters, numbers and alphabets with blank without using this method a = a.replaceAll(".","");
to replace entire string with blank?
Is there any other way ??
Pshemo :
I am not sure what you want to achieve, but if you want to combine two character sets you can \n\n\nuse OR operator like [oneSet]|[secondSet] \nplace them in other set like [[oneSet][secondSet]] \n\nwhich can also be simplified to [oneSet[secondSet]] so maybe you are looking for something like \n\n\n\n\n\na = a.replaceAll(\"[a-zA-Z0-9[^\\\\w\\\\s-_]]\",\"\");\n\n\n\n\nDemo: I will replace found characters with X to show exactly which characters ware replaced\n\nString a = \"abcd ABCD 0123 !@#$%^&*()\";\nSystem.out.println(a.replaceAll(\"[a-zA-Z0-9]\", \"X\"));\nSystem.out.println(a.replaceAll(\"[^\\\\w\\\\s-_]\", \"X\"));\nSystem.out.println(a.replaceAll(\"[a-zA-Z0-9[^\\\\w\\\\s-_]]\", \"X\"));\n\n\nOutput:\n\nXXXX XXXX XXXX !@#$%^&*()\nabcd ABCD 0123 XXXXXXXXXX\nXXXX XXXX XXXX XXXXXXXXXX\n",
2014-09-27T18:26:52
Rimas :
Combine with |:\n\na=a.replaceAll(\"[a-zA-Z0-9]|[^\\\\w\\\\s-_]\", \"\");\n",
2014-09-27T18:20:40