I've seen people do the following:
if (/Firefox\/(\+S)/.test(userAgent)) {
firefox = RegExp.$1;
}
I know (sorta) what the regexp does, but I'm not really sure how it can be accessed with RegExp.$1
.
And as a side note:
if (/Win(?:dows )?([^do]{2})\s?(\d+\.\d+)?/.test(ua)) {
if (RegExp.$1 == "NT") {
switch (RegExp.$2) {
What's the difference between $1
and $2
?