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

PREVIOUS NEXT
Code Example
Javascript :: how to make 1st letter capital in ejs 
Javascript :: remover clase jquery 
Javascript :: how to get current day in javascript 
Javascript :: javascript object get element by index 
Javascript :: Set node environment through package.json script 
Javascript :: add firebase angular 
Javascript :: remove duplicates from array js lodash 
Javascript :: traverse 2d array js 
Javascript :: how to implement toastr 
Javascript :: replace non alphanumeric javascript 
Javascript :: textalign javascript 
Javascript :: regex diferent of 
Javascript :: Convert underscore strings to camel Case 
Javascript :: javascript how to print working directory 
Javascript :: brackets not autocompleting in js file in vscode 
Javascript :: update tooltip jquery 
Javascript :: how to block special characters in javascript 
Javascript :: node.js socket.io send data with handshake 
Javascript :: sequelize find one 
Javascript :: upsert mongoose 
Javascript :: geolocation in javascript 
Javascript :: map function react not appearing 
Javascript :: jquery datepicker re initialize 
Javascript :: capitalize in javascript 
Javascript :: javascript loop over class 
Javascript :: add class on javascript onclick function 
Javascript :: replace all spaces with dash in javascript 
Javascript :: place footer at the bottom of the page react 
Javascript :: how use replace in js for all things at once 
Javascript :: javascript log Time from Date 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =