Censoring selected words (replacing them with ****) using a single replaceAll?
Posted
by aioobe
on Stack Overflow
See other posts from Stack Overflow
or by aioobe
Published on 2010-06-03T13:05:04Z
Indexed on
2010/06/03
13:14 UTC
Read the original article
Hit count: 158
I'd like to censor some words in a string by replacing each character in the word with a "*". Basically I would want to do
String s = "lorem ipsum dolor sit";
s = s.replaceAll("ipsum|sit", $0.length() number of *));
so that the resulting s
equals "lorem ***** dolor ***"
.
I know how to do this with repeated replaceAll
invokations, but I'm wondering, is this possible to do with a single replaceAll
?
© Stack Overflow or respective owner