Adding mutiple values in regex for pattern match

I am trying to add multiple strings in regex and then test them against certain value to see if that string exists.

 var pattern = new RegExp("^"+"ABC","i");
 var patternMatch= pattern.test(SomeArray[0]);

Now I require to add multiple string values in regex and then test if it exists in array.
Something like this :

var pattern = new RegExp("^"+"ABC" | "XYZ","i"); 
var patternMatch= pattern.exists(SomeArray[0]);

Can something like thisbe achieved

Source: JavaSript – Stack Overflow

November 25, 2021
Category : News
Tags: javascript | regex

Leave a Reply

Your email address will not be published. Required fields are marked *

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.