mardi 23 juillet 2019

I am not able to use /[^\s]/ regex in javascript test function to detect any occurrence of spaces in given string [duplicate]

This question already has an answer here:

Both results: res1 and res2 give value: true, irrespective of space is added in the string or not.

var res1 = /[^\s]/.test("demotest");

var res2 = /[^\s]/.test("demo test");

The expected result should be: false for res2 and true for res1.

Aucun commentaire:

Enregistrer un commentaire