Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

regex to check non empty string

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

regex to match empty string

/^$/ // match exactly ""
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 :: discord.js how to use subcommands 
Javascript :: chartjs how to disable hover lable 
Javascript :: changing the active class on press 
Javascript :: generate random string javascript 
Javascript :: open new tab with angular router 
Javascript :: js check if two array have the same element 
Javascript :: javascript prevent space from scrolling 
Javascript :: bootstrap multiselect change value 
Javascript :: exit extension from chrome javascript 
Javascript :: javascript padend 
Javascript :: random id number nodejs 
Javascript :: filter includes array 
Javascript :: js check if radio button is checked 
Javascript :: npm install run audit fix 
Javascript :: jquery set a value in td 
Javascript :: react router history push parameter 
Javascript :: how to create infinite loop in javascript 
Javascript :: get element or class 
Javascript :: click outside element jquery 
Javascript :: ajax uploading progress 
Javascript :: search if value exists in object javascript 
Javascript :: jquery click outside 
Javascript :: javascript string includes 
Javascript :: javascript set element width 
Javascript :: splidejs autoscroll 
Javascript :: vue dev server proxy not working 
Javascript :: HashLocationStrategy 
Javascript :: flutter parse json 
Javascript :: javascript random int in range 
Javascript :: how to run nextjs in another port 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =