Last active
March 4, 2021 06:07
-
-
Save afulsamet/72c7d40ebc5da267c397e32f4a72b15b to your computer and use it in GitHub Desktop.
Censor bad words with JavaScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Regex = { | |
BadWords: /(bad word|can't censor me)/g | |
}, IString = "hey, i'm a bad word and you can't censor me"; | |
IString.replace(new RegExp(Regex.BadWords), RString => Array.from(RString).map(() => "*").join(String())) | |
// Output: "hey, i'm a ******** and you ***************" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment