我编写了一个Java程序来删除字符串
中的所有标点符号"1.1 Interactive systems In today's world, interacting with computer-based devices and systems is commonplace."
如何使用正则表达式删除带有此字符串的标点符号
"11 Interactive systems In todays world interacting with computerbased devices and systems is commonplace".
答案 0 :(得分:0)
使用字符串replaceAll和正则表达式
String mystring = "\"1.1 Interactive systems In today's world, interacting with computer-based devices and systems is commonplace.\"";
String replaced = mystring.replaceAll("\\p{Punct}", "");
实际正则表达式是\p{Punct}
但我们需要转义\
因此另一个反斜杠。
输出
11 Interactive systems In todays world interacting with computerbased devices and systems is commonplace