How do I use a javascript regular expression to check a string that does not match certain words?
For example, I want a function that, when passed a string that contains either abc
or def
, returns false.
'abcd' -> false
'cdef' -> false
'bcd' -> true
EDIT
Preferably, I want a regular expression as simple as something like, [^abc], but it does not deliver the result expected as I need consecutive letters.
eg. I want myregex
if ( myregex.test('bcd') ) alert('the string does not contain abc or def');
The statement myregex.test('bcd')
is evaluated to true
.