java - 如何使用java / android中的正则表达式从字符串中删除所有字母字符?
val = val.replaceAll("/A/z","");
Try this:
replaceAll("[a-z]", "");
Also have a look here:
Have a look into Unicode properites:
\p{L}
any kind of letter from any language
So your regex would look like this
val = val.replaceAll("\\p{L}+","");
To remove also combined letters use a character class and add \p{M}
\p{M}
a character intended to be combined with another character (e.g. accents, umlauts, enclosing boxes, etc.)
Then you end here:
val = val.replaceAll("[\\p{L}\\p{M}]+","");
This will remove all alphabetical characters
String text = "gdgddfgdfh123.0114cc";
String numOnly = text.replaceAll("\\p{Alpha}","");