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
?
Update: It's a part of a research case-study and the reason is basically that I would like to get away with a one-liner as it simplifies the generated bytecode a bit. It's not for a serious webpage or anything.