用正则表达式去掉一句话中的标点符号、空格和一些能想到的特殊符号
// 去除 符号 和空格(中英文)
public String delSignBlank( String str){
str = str.replaceAll("(?i)[^a-zA-Z0-9\u4E00-\u9FA5]", "");
// str = str.replace('-', ' ').replace(':', ' ').replaceAll(" ",""); 只是去掉空格
return str;
}
// 去除 符号 和空格(中英文)
public String delSignBlank( String str){
str = str.replaceAll("(?i)[^a-zA-Z0-9\u4E00-\u9FA5]", "");
// str = str.replace('-', ' ').replace(':', ' ').replaceAll(" ",""); 只是去掉空格
return str;
}
本文介绍了一种使用正则表达式去除文本中包括标点符号、空格及其他特殊符号的方法。通过简单的代码实现,可以有效清理文本数据,为后续处理提供干净的基础。
5041

被折叠的 条评论
为什么被折叠?



