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 :: regular expression to remove underscore from a string javascript 
Javascript :: onclick toggle class react 
Javascript :: days difference in moment js 
Javascript :: discord.js bot mention 
Javascript :: check if key does not exists in dictionary javascript 
Javascript :: javascript null true or false 
Javascript :: javascript get element by id 
Javascript :: get random item from array javascript 
Javascript :: canvas js filter greyscale 
Javascript :: use eslint in vscode 
Javascript :: react and react dom cdn 
Javascript :: get last two digits of year javascript 
Javascript :: browserslisterror contains both .browserslistrc and package.json with browsers 
Javascript :: js  
Javascript :: detect if two line segments intersect each other javascript 
Javascript :: ajax syntax in javascript 
Javascript :: JS automate a click 
Javascript :: onclick change image javascript example 
Javascript :: Material-ui add alert icon 
Javascript :: js array of objects get a specific key from all objects 
Javascript :: javascript format date 
Javascript :: javascript dir 
Javascript :: let in javascript 
Javascript :: bodyparser deprecated vscode 
Javascript :: jquery remove class 
Javascript :: bootstrap datepicker mindate and maxdate 
Javascript :: linear gradient css react js 
Javascript :: javascript object chain 
Javascript :: array to object 
Javascript :: clean url javascript 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =