I want to know if Javascript RegExp has the ability to turn on and off case insensitivity within the regular expression itself. I know you can set the modifier for the entir
Why not simply use 2 Regex's?
var str = "teXT To seArcH TOP SECRET";
if (/text to search/i.test(str) && /TOP SECRET/.test(str)) {
console.log('match!');
}
I think there is rarely a good reason to make a single very complex regex to cover every case, when you could instead make a handful of Regex's which you combine with code logic. I'd much rather have small bite size Regex's from a maintenance point of view, as figuring what a complex regex actually does can be quite daunting.