Created
May 9, 2017 02:11
-
-
Save ryanve/004dcaecf1fe4835345385b4d1500c78 to your computer and use it in GitHub Desktop.
JavaScript regex to blacklist words
This file contains hidden or 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
/^(?!(corn|bread)$).+/.test('corn') // false (blacklisted) | |
/^(?!(corn|bread)$).+/.test('bread') // false (blacklisted) | |
/^(?!(corn|bread)$).+/.test('cornbread') // true (not blacklisted) | |
/^(?!(corn|bread)$).+/.test('corndog') // true (not blacklisted) | |
/^(?!(corn|bread)$).+/.test('read') // true (not blacklisted) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://regex101.com/r/ANLnw9/4