Censoring selected words (replacing them with ****) using a single replaceAll?
- by aioobe
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?