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 :: javascript stop setinterval 
Javascript :: js object length 
Javascript :: how to redirect programatically in nextjs 
Javascript :: disable yellow box react native 
Javascript :: update node .js 
Javascript :: JsonException: A possible object cycle was detected. This can either be due to a cycle or if the object depth is larger than the maximum allowed depth of 32. Consider using ReferenceHandler.Preserve on JsonSerializerOptions to support cycles. 
Javascript :: how to assign port in angular 
Javascript :: update nodejs version in ubuntu 
Javascript :: wp_enqueue_script bootstrap 
Javascript :: import menu material ui 
Javascript :: flash input js 
Javascript :: javascript check uncheck checkbox 
Javascript :: how to remove underline from material ui select 
Javascript :: react-redux imports 
Javascript :: when do we use scroll listener in javascript 
Javascript :: open new tab with javascript 
Javascript :: how to insalk react router with npm 
Javascript :: check if is array js 
Javascript :: cypress set viewport 
Javascript :: js sync delay 
Javascript :: javascript clear style inline property 
Javascript :: Node Sass version 5.0.0 is incompatible with ^4.0.0 
Javascript :: get first 10 items of array javascript 
Javascript :: js change root css variable 
Javascript :: if document is loaded 
Javascript :: remove duplicate strings from array javascript 
Javascript :: kendo angular grid date format 
Javascript :: create-react native app without expo 
Javascript :: ion button transparent 
Javascript :: byte to gb javascript 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =