有下一行:
String filtered = data.replaceAll("//[ /,]"," ");
数据类似于[" blahblah"," blahblah"],但没有任何好处发生
如何删除所有不必要的符号并像#34; blablah blahblah"过滤?
答案 0 :(得分:5)
使用此模式:
"\\W+"
"
分隔符\
转义\
\W+
匹配一个或多个非单词字符完整代码:
String filtered = data.replaceAll("\\W+","");
答案 1 :(得分:2)
如果您想在需要替换的单词之间留出空格,请填写“”:
String filtered = data.replaceAll("\\[|\\]|\"","");
filtered = filtered.replaceAll(","," ");
现在的输出是“blahblah blahblah”