I want to know (with examples!) if there is a way to search through a list (not a file) and if it’s found replace it.
Background: Making a server but I want it to censor swear words and the system i have works it’s just not efficient enough.
Current Code:
String impmessage = message.replaceAll("swearword1", "f***");
String impmessage2 = impmessage.replaceAll("swearword2", "bi***");
String impmessage3 = impmessage2.replaceAll("swearword3", "b***");
String impmessage4 = impmessage3.replaceAll("swearword4", "w***");
...
String impmessage8 = impmessage7.replace('%', '&');
The whole shabang. But when I want to add a new word into the filter I have to add another one on there.
Your basic solution is below:
How you create the mapping is somewhat up to you. Here is another more comprehensive solution including pulling in from a random file: