Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

regex to check non empty string

/^(?!s*$).+/
Comment

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
Comment

regex for non empty string

^(?!s*$).+
Comment

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
Comment

PREVIOUS NEXT
Code Example
Javascript :: add class jquery 
Javascript :: joi validation compare two password 
Javascript :: clear file upload jquery 
Javascript :: lodash angular 9 
Javascript :: reactive forms change event in angular 
Javascript :: Use the parseInt Function with a Radix 
Javascript :: javascript average of arguments 
Javascript :: how to get seconds in timstamps js 
Javascript :: random rgba color javascript except black 
Javascript :: how to use typeof in javascript 
Javascript :: import react icons 
Javascript :: firebase app named default already exists react native 
Javascript :: jquery get body 
Javascript :: Deep copy objects js JSON methods 
Javascript :: javascript nth root 
Javascript :: mongodb add new field 
Javascript :: javascript to remove duplicates from an array 
Javascript :: async for loop 
Javascript :: File line by line reader Node js 
Javascript :: jquery table row count 
Javascript :: React site warning: The href attribute requires a valid address. Provide a valid, navigable address as the href value jsx-a11y/anchor-is-valid 
Javascript :: moment js from now 
Javascript :: javascript run command 
Javascript :: angularjs accordion access toggle 
Javascript :: run jest on single file 
Javascript :: first letter of each word in a sentence to uppercase javascript 
Javascript :: javascript remove duplicates from array 
Javascript :: javascript find all matches in array 
Javascript :: angular http put 
Javascript :: array vowels 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =