I have a string:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 (.NET CLR 3.5.30729)
I want to know what version of Firefox is in the string (3.5.2).
My current regex is:
Firefox\/[0-9]\.[0-9]\.[0-9]
and it returns Firefox/3.5.2
I only want it to return 3.5.2
from the Firefox version, not the other versions in the string. I already know the browser is Firefox.
/(?<=Firefox\/)\d+(?:\.\d+)+/
will return 3.5.2 as the entire match (using lookbehind - which is supported in most browsers nowadays).
If your JavaScript engine still does not support this (looking at Safari in February 2022), search for /Firefox\/(\d+(?:\.\d+)+)/
and use match no. 1.
Since in theory there could be more than one digit (say, version 3.10.0), I've also changed that part of the regex, allowing for one or more digits for each number.