Answers for "regex for check if string is only empty or whitespace javascript"

2

javascript regex check if string is empty

function IsEmptyOrWhiteSpace(str) {
    return (str.match(/^\s*$/) || []).length > 0;
}
Posted by: Guest on April-23-2021
0

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);
 }
Posted by: Guest on September-09-2021

Code answers related to "regex for check if string is only empty or whitespace javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language