Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js store regex in variable and combine

const a = /a/
const b = /b/
// Concatenate two Regular Expressions with an OR |
const c = new RegExp( a.source + "|" + b.source );
// c --> /a|b/

"a".match(c)
// ["a", index: 0, input: "a", groups: undefined]
"b".match(c)
// ["b", index: 0, input: "b", groups: undefined]
"c".match(c)
// null
Comment

PREVIOUS NEXT
Code Example
Javascript :: js new element 
Javascript :: model mongoose 
Javascript :: javascript es6 class 
Javascript :: get element by class name 
Javascript :: document.getelementbyid 
Javascript :: three.js cube 
Javascript :: Download excel using reactJS 
Javascript :: javascript remoe last character from string 
Javascript :: add items to a react array in hooks 
Javascript :: javascript select element with two classes 
Javascript :: how to push key value pair to object javascript 
Javascript :: get json data into array of object 
Javascript :: try and catch express 
Javascript :: invoking jquery validator 
Javascript :: readfilesync buffer 
Javascript :: next js styled components classname did not match 
Javascript :: what is super(props) in react 
Javascript :: ssg full form in nextjs 
Javascript :: foreach method javascript 
Javascript :: put new attribute on html tag using javascript 
Javascript :: delete element of array javascript 
Javascript :: how to exit node 
Javascript :: how to get a due date from current date in javascript 
Javascript :: currentTime(); javascript 
Javascript :: for:each in lwc js 
Javascript :: ant design charts 
Javascript :: js how to calculate factorial 
Javascript :: How to convert a canvas to an image javascript 
Javascript :: axios all methods 
Javascript :: find max number in java 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =