Reputation: 11
I have a problem with characters String which i want to replace all with spaces.
I have a paragraph which contains some Strings like that {〭}
So I want to replace them with spaces.
I used this function:
{text=text.replaceAll("&#[1-9];", "");}
but it doesn't work
Upvotes: 1
Views: 8339
Reputation: 43673
I suggest to use
text = text.replaceAll("&#\\d+;", " ");
however in case &#...
sequences are automatically converted into characters, use
text = text.replaceAll("[^\\x20-\\x7F]", " ");
Upvotes: 0
Reputation: 500257
Your regex looks for exactly one digit. Change it to:
"&#[1-9]+;"
(note the added +
).
Also, the [1-9]
is probably incorrect, and should be [0-9]
(or indeed [0-9A-Fa-f]
if the digits are hex).
Upvotes: 1