使用正则表达式从定界字符串中获取值
Fetch value from delimited string using Regex
我有一个分析工具,它允许我获取正则表达式并使用正则表达式提取字符串的特定部分。在下面的示例中,我希望使用分隔符“:”提取第三个槽中的值,并且我可以使用 $
将值引用到 return。
示例键
mfast_acquired_theresasale
alp:psch_nb_b2b:thisisthekeyword:thisistheoccassion
alp:psch_nb:paid keyword:rewardsclub
alp:psch_nb:gifts:sale
alp:psch_things:keyword_phrase
预期结果
(没有匹配预期)
这是关键词
付费关键词
礼物
keyword_phrase
到目前为止我合理地尝试过:
这失败了 --> ^alp:([^:]+)$
这失败了 --> ^alp.*:([^:]+)$
然后我将 $1 引用到 return 匹配的内容
我尝试过的返回结果:
没有匹配 returned
我觉得你可以用
^alp:[^:]+:([^:]+)
^^^^^^
详情:
^
- 字符串开头
alp:
- 文字 alp:
[^:]+
- :
以外的 1 个或多个字符
:
- 冒号
([^:]+)
- 第 1 组捕获 1 个或多个非 :
s
如果 GA 需要完整的字符串匹配,请使用 ^alp:[^:]+:([^:]+).*$
。
我有一个分析工具,它允许我获取正则表达式并使用正则表达式提取字符串的特定部分。在下面的示例中,我希望使用分隔符“:”提取第三个槽中的值,并且我可以使用 $
将值引用到 return。
示例键
mfast_acquired_theresasale
alp:psch_nb_b2b:thisisthekeyword:thisistheoccassion
alp:psch_nb:paid keyword:rewardsclub
alp:psch_nb:gifts:sale
alp:psch_things:keyword_phrase
预期结果
(没有匹配预期)
这是关键词
付费关键词
礼物
keyword_phrase
到目前为止我合理地尝试过:
这失败了 --> ^alp:([^:]+)$
这失败了 --> ^alp.*:([^:]+)$
然后我将 $1 引用到 return 匹配的内容
我尝试过的返回结果: 没有匹配 returned
我觉得你可以用
^alp:[^:]+:([^:]+)
^^^^^^
详情:
^
- 字符串开头alp:
- 文字alp:
[^:]+
-:
以外的 1 个或多个字符
:
- 冒号([^:]+)
- 第 1 组捕获 1 个或多个非:
s
如果 GA 需要完整的字符串匹配,请使用 ^alp:[^:]+:([^:]+).*$
。