简体   繁体   中英

Regex match pattern into a characters string OR another pattern in the same characters string

I need your help for my Google Tag Manager settings.

I'd like a trigger to fire if an item number from a list is recognized in a characters string.

Let's give an example. My item list:

11310
11311
11312
11313

If the DOM Element contains 11310 OR 11311 0R 11312 OR 11313 into a characters string, then the trigger should fire.

Could you please help to create the relevant RegEx?

Thanks

you can do

 function match(str){ return str.match(/^1131[0-3]$/) != null; } console.log(match('11310')); console.log(match('11311')); console.log(match('11312')); console.log(match('11313')); console.log(match('11314'));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM