Hi all..
I'd like to ask how to remove all non-letter characters from a
string.
e.g. if I have string "Great Javaranch" or "Gre745at Java{}#@$ranch "
and I pass each of them into specific method ( e.g. format(String) ), the method will returns "GreatJavaranch".
I know that there is a method String.replaceAll. However, my problem is how to check all non-letter character without cumbersome code or iteration.
I surely don't want to write something like
if (string.contains('.')) {
string = string.replaceAll('.', null);
}
if (string.contains('$')) {
string = string.replaceAll('.', null);
}
...
...
Or, if I have to, maybe it will be nice to have a list of all non-letter-recognized-by-java-characters, and iterate using that list. But I don't know how to get such list, and even if I can, it will be a cumbersome iteration.
Does regex works for this problem? If so, how?
Thanks