Regex for empty string or white space
If you are looking for empty string in addition to whitespace you meed to use * rather than +
var regex = /^\s*$/ ;
^
The \
(backslash) in the .match
call is not properly escaped. It would be easier to use a regex literal though. Either will work:
var regex = "^\\s+$";
var regex = /^\s+$/;
Also note that +
will require at least one space. You may want to use *
.