Answers for "regex empty string"

1

regular expression to remove empty lines after text

Find: ^(?:[\t ]*(?:\r?\n|\r))+
Replace: ""
Posted by: Guest on April-29-2020
1

regex to check non empty string

/^(?!\s*$).+/
Posted by: Guest on November-17-2020
0

regex empty string

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
0

regex is not empty string

const REGEXP = /^$/;

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

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

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

regex for non empty string

^(?!\s*$).+
Posted by: Guest on July-14-2021

Browse Popular Code Answers by Language