// You can use (?!...) like the example below let names = ['JOAO', 'JOHN', 'JOANA', 'JOABE']; for(let n of names) { /(JO)(?!A)/.test(n); // only true on 'JOHN' }
^((?!hede).)*$