I have some javascript code that I don’t wish to make an edge case for, and it just so happens that I need to add a regex that fails every possible input string, including an empty string.
More specifically, I need a regex that returns false
for every possible value of str
when running regex.test(str)
.
I found this regex to work quite nicely:
/[]/
console.log(/[]/.test('hello'));
console.log(/[]/.test('[]'));
console.log(/[]/.test(''));