I\'m wondering if I can use string.replace() to replace all alphabets in a string?
string.replace()
String sentence = \"hello world! 722\" String str = sentence
You can use the following (regular expression):
String test = "hello world! 722"; System.out.println(test); String testNew = test.replaceAll("(\\p{Alpha})", "@"); System.out.println(testNew);
You can read all about it in here: http://docs.oracle.com/javase/tutorial/essential/regex/index.html