【问题标题】:Regex match pattern into a characters string OR another pattern in the same characters string正则表达式将模式匹配为字符串或相同字符串中的另一个模式
【发布时间】:2017-09-26 07:55:09
【问题描述】:

我的 Google 跟踪代码管理器设置需要您的帮助。

如果列表中的项目编号在字符串中被识别,我希望触发触发器。

让我们举个例子。我的物品清单:

11310
11311
11312
11313

如果 DOM 元素包含 11310 OR 11311 0R 11312 OR 11313 到字符串中,那么触发器应该触发。

您能帮忙创建相关的 RegEx 吗?

谢谢

【问题讨论】:

    标签: javascript regex google-tag-manager


    【解决方案1】:

    你可以的

    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'));

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-14
      • 1970-01-01
      • 1970-01-01
      • 2014-04-10
      • 2022-01-18
      相关资源
      最近更新 更多