Alter Regular Expression to Return 2 Values Instead of 3 from userAgent String

Posted by Jay on Stack Overflow See other posts from Stack Overflow or by Jay
Published on 2010-04-30T00:12:50Z Indexed on 2010/04/30 0:17 UTC
Read the original article Hit count: 246

Filed under:
|
|

I've taken a regular expression from jQuery to detect if a browser's engine is WebKit and gets it's version number, it returns 3 values extracted from the userAgent string: webkit/….…, webkit and ….… [“….…” being the version number].

I would like the regular expression to return just 2 values: webkit and ….….

I'm rubbish at regular expressions, so please can you give an explanation of the expression with your answer.

The regular expression I'm currently working with and wish to improve is: /(webkit)[\/]([\w.]+)/.

I appreciate all your help, thanks in advance!

© Stack Overflow or respective owner

Related posts about useragent

Related posts about JavaScript