[英]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.我需要您帮助我进行 Google 跟踪代码管理器设置。
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.如果 DOM 元素包含11310
OR 11311
0R 11312
OR 11313
到一个字符串中,那么触发器应该被触发。
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'));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.