Detect WebKit Version 525 and Below With RegEx

Posted by Jay on Stack Overflow See other posts from Stack Overflow or by Jay
Published on 2010-04-28T23:06:00Z Indexed on 2010/04/28 23:07 UTC
Read the original article Hit count: 386

I'm no good at Regular Expressions, really!

I would like to specifically detect WebKit browsers below version 525.

I have a regular expression [/WebKit\/[\d.]+/.exec(navigator.appVersion)] that correctly returns WebKit/5….…, really, I'd like it to return only the version number, but if the browser isn't WebKit, return null, or better still 0.

For example, if the browser was Trident, Presto or Gecko, return null, whereas if the browser is WebKit, return it's version number.

To clarify, I would like the regular expression to check if navigator.appVersion contains WebKit and if it does not, return null, if it does, return the version number.

I appreciate all your help!

Please let's keep this focused, let's not flirt with jQuery or the sort, it's overkill in this scenario.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about regex