0
/\w+/.test('@asd') // true
/\w+/.test('@') // false
/\w+/.test('asd') // true

Shouldn't the first one return false as well? consider there is a special character inside the string.

I did read thought the doc: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test probably missed something important

The test() method executes a search for a match between a regular expression and a specified string. Returns true or false.

please correct me on which part am i missing here to not getting the expected result.

Bill
  • 17,872
  • 19
  • 83
  • 131

0 Answers0