I am creating a website which include a comment area for users. Example a guestbook or a product review. And I want to restrict a user on posting inappropriate languages on the comment area. For example: vulgarities.
If the user input any vulgarities, the characters would be replace by * . *Example – from stupid to s * * * * **.
I had been researching on related website but it was unfruitful. Suggestions or tutorials on this would be greatly appreciated.
There is no way to fully stop “bad language” from being used but you can try to prevent it by creating a text file that contains a bad word in every line. Then load the list of words from the file to a
List<String>in your program. You can do so by doing the following:Then, to determine if a string has one of these bad words you do the following: