对正则表达式相当陌生。我希望能够删除除 $ 之外的所有非字母数字字符。
所以对于像“I am here $today#”这样的字符串,结果应该是“I am here $today”
我已经尝试过了,但没有成功。
[^a-zA-Z\\s$] and [$^a-zA-Z\\s] and [^a-zA-Z$\\s]
最佳答案
String regex = "[^a-zA-Z\\s$]";
String string = "I am here $today#";
string = string.replaceAll(regex, "");
System.out.println(string); // I am here $today
这工作得很好......
关于java - 用于删除除 $ 之外的所有非字母数字字符的正则表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34516120/