Reputation: 161
Having next line:
String filtered = data.replaceAll("//[ /,]"," ");
where data is like to ["blahblah","blahblah"], but nothing good happens
How to remove all unnecessary symbols and get filtered like "blablah blahblah"?
Upvotes: 2
Views: 1859
Reputation: 188
If you want to have a space between words you need to replace , to " ":
String filtered = data.replaceAll("\\[|\\]|\"","");
filtered = filtered.replaceAll(","," ");
Now the output is "blahblah blahblah"
Upvotes: 3
Reputation: 10340
Use this pattern:
"\\W+"
"
delimiter\
escapes \
\W+
match one or more non-word character(s)Full code:
String filtered = data.replaceAll("\\W+","");
Upvotes: 7