Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

regex for check if string is only empty or whitespace javascript

//empty string or white space
function hasWhiteSpace(value) {
  return /^s*$/.test(value);
}

// empty string or string with white space 
function hasWhiteSpace(value) {
  return /^$|s+/.test(value);
 }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #regex #check #string #empty #whitespace #javascript
ADD COMMENT
Topic
Name
9+6 =