I wanted to test userAgent by a Regexp
the goal :
true if UA contains "AppleWebKi t/528+ " or "AppleWebKi t/525.12+ " note
the final "+"
false otherwise
then i wrote :
var re=new Regexp(" AppleWebKit/[^ ]+\+ ");
var isWebkitNightly =re.test(naviga tor.userAgent);
and i got the following error with Firefox3RC1 :
invalid quantifier +
however, testing that way :
var isWebkitNightly =/ AppleWebKit\/[^ ]+\+ /.test(navigator .userAgent);
works fine.
why ?
--
Une Bévue
the goal :
true if UA contains "AppleWebKi t/528+ " or "AppleWebKi t/525.12+ " note
the final "+"
false otherwise
then i wrote :
var re=new Regexp(" AppleWebKit/[^ ]+\+ ");
var isWebkitNightly =re.test(naviga tor.userAgent);
and i got the following error with Firefox3RC1 :
invalid quantifier +
however, testing that way :
var isWebkitNightly =/ AppleWebKit\/[^ ]+\+ /.test(navigator .userAgent);
works fine.
why ?
--
Une Bévue
Comment