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 entire regex expression, but that isn't what I'm talking about.
For example, my search string could be:
teXT To seArcH TOP SECRET.
I want to find the insensitive case part "text to search" and then force case sensitivity for "TOP SECRET".
Thus, this wouldn't match (because of case sensitivity for top secret):
teXT To seArcH Top Secret
but this would match (first section case doesn't matter):
text to search TOP SECRET
In Perl, you can do this within the search string. Does Javascript's regular expression engine support anything like this?
(?i:...). You pretty much have to do it yourself/[tT][eE][xX][tT] TOP SECRET/, or break your test in two:var m = /text TOP SECRET$/i.match(s); m = m && m[0].match(/TOP_SECRET$/).