Search code examples
javascriptjslint

JSLint : How to resolve Expected '\s' and instead saw ' '. warning


Below is my js code and i get Expected '\s' and instead saw ' '. error. Can somebody help me to resolve this error.

osVersion = /Mac OS X (10[._\d]+)/.exec(nAgt)[1];


Solution

  • Since JSLint complains about whitespaces not being regexed replace all whitespaces with \s

    osVersion = /Mac\sOS\sX\s(10[._\d]+)/.exec(nAgt)[1];