I'm trying to set up a context & reaction to load certain assets only if the browser is NOT IE8 or earlier (along with some other conditions but that's what matters for the moment). So I want a regexp that the useragent context will return as 'true' against user agent strings for Firefox, Chrome, etc., but which the useragent context will show as 'false' for any version of IE.

I've tested the following regexp and it returns a 0-length string for an IE7 user agent string: (?!MSIE [5678])

However, Context Useragent seems to treat it as equivalent to this: MSIE [5678]

It's certainly possible my regexp is wrong, but I think I'm missing something about how to provide an argument to this module.

Comments

escoles’s picture

Title: Trouble making negation regexp work » Regexp and its negation produce equivalent result
escoles’s picture

Title: Regexp and its negation produce equivalent result » Regex for negation
Status: Active » Closed (fixed)

I got the results I needed by negating values within the string, like this:

MSIE [^1-8]

I'm still not sure why the lookaround didn't work for me, and probably won't have the time to figure it out. But this pretty simple string and variations thereon can be used to test for the presence of IE 1-8 . (Not that anyone reading this has actually seen IE1 in the wild in 15 years, but one should be thorough...)

EDIT: As formulated, this catches IE10 and IE11.

MSIE [^678]

is safer, especially given the current rate of updates from MS.

RE-EDIT: actually, none of these will work. Leaving this closed as I think this module actually doesn't support negation very usefully in its current form.