Regex match reverse group in javascript

javascript, regex

Solution

Use negative lookaead:

/^(?!.*?(abc|def|ghi)).*$/

Problem

I want to match strings that don't have `abc`, `def` or `ghi`. The opposite is easy: ``` /(abc|def|ghi)/ ``` How do I reverse that? I don't want to ``` /(^abc|^def|^ghi)/ ``` because there's going to be more 'logic' in there. (If that's even what it does.) How do I reverse the whole group match (or whatever it's called)? (I'm trying to beat 5. on http://regex.alf.nu/)

Original source

Related problems