Google Tag Manager -Regex Match

发布于 2025-01-22 21:31:44 字数 548 浏览 1 评论 0原文

我想检查GTM变量中是否包含特定字符串。该变量的值是通过URI进行解码的第一方 - 奇异值:

"\"prodirversion\":5,\"panellanguage\":\"de\",\"preferences\":false,"\"marketing\":true,\"necessary\":true,\"statistics\":false,\"social_"

我现在想检查是否包括以下字符串。

营销”:True

我使用正则表格创建了另一个变量,并尝试了不同的正则表达式,但似乎无效。它在在线REGEX Tester上起作用,但在Google Tag Manager中不起作用。

我的猜测将是以下内容 不起作用

marketing\\":true

marketing.{3}true 

marketing\\.{2}true

I want to check if a specific string is included in a GTM variable. The value of this variable is a first-party-cookie value decoded via URI looking like this:

"\"prodirversion\":5,\"panellanguage\":\"de\",\"preferences\":false,"\"marketing\":true,\"necessary\":true,\"statistics\":false,\"social_"

I now want to check if the following string is included.

marketing":true

I created another variable with a regex table and tried different regex expressions but nothing seems to work. It works on online regex tester but not in Google Tag Manager.

My guess would be the following but it doesn't work.

marketing\\":true

or

marketing.{3}true 

or

marketing\\.{2}true

GTM variable

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

分開簡單 2025-01-29 21:31:44

某些正则发动机将在不逃脱 char in Marketing \ \”中遇到错误:true

尝试这样逃脱:Marketing> Marketing \\\\':true << /code>,它应该匹配

  • <代码>营销:true 似乎在gtm中工作
  • ,我们可以得出结论代码>在输入字符串中仅在GTM情况下显示,当Regex测试/调试时,应忽略。

Some Regex engines will have an error on not escaping " char in marketing\\":true

Try escaping it like this: marketing\\\":true, and it should match.

Update:

  • marketing":true seems to be working in GTM
  • from that, we can conclude that escaping character \ in input string is for show only in GTM case, and should be ignored when regex testing/debugging.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文