Answers for "regex is empty string 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 is empty string javascript

const REGEXP = /^$/;

const validate = (text) => {
    return REGEXP.test(text);
}

const isEmpty = validate("");
const isNotEmpty = validate("x");

console.log(isEmpty); //true
console.log(isNotEmpty); //false
Posted by: Guest on May-24-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language