I need to match Safari browsers, but not Chrome browsers using one Regex. I usually don’t have a problem with regex, but negative look-aheads are stumping me here.
/(?!chrome)(safari)/i.test("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5");
Can’t figure out why this is returning true.
This will do it
BTW JavaScript does not support lookbehind but I see no problem with lookahead.
What you are saying with
Is that right before “safari” (zero width so starting with the cursor before s) there cannot be the string “chrome” which doesn’t make sense.