[英]How can I use regex for “contains this word”
I'm trying to setup tracking in Google Analytics. 我正在尝试在Google Analytics(分析)中设置跟踪。
The goal URL is: 目标网址为:
www.example.com/2006/blog-post_4.html
www.example.com/2006/blog-post_4.html?m=0
www.example.com/2006/blog-post_4.html?m=1
ignore 忽视
www.example.com/2006/blog-post_40.html
www.example.com/2006/blog-post_4.html#hashtag
www.example.com/2006/blog-post_4.html?m=0#hashtag
www.example.com/2006/blog-post_4.html?m=1#hashtag
my attempt 我的尝试
.*blog-post_4(.html|.html.m=.)?(?!..)
Google Analytics automatically disregards fragments, so you won't need to worry about filtering them out. Google Analytics(分析)会自动忽略片段,因此您无需担心将其过滤掉。
So your destination goal configuration can be something like this, which ignores those strings that you've indicated (which in the end is really just the one with blog-post_40.html
: 因此,您的目标目标配置可以是这样的,它会忽略您指示的那些字符串(最后实际上只是带有
blog-post_40.html
:
You may use 您可以使用
blog-post_4[.]html([?]m=[0-9]+)?$
This regex will match blog-post_4
literslly, then a literal dot will get matched with [.]
followed with a literal character sequence html
followed with an optional group (since it is enclosed with parentheses followed immediately with a ?
quantifier) that matches a question mark, m=
+ one or more digits, and then followed with an end of string marker. 此正则表达式将与
blog-post_4
literslly匹配,然后文字点将与[.]
匹配,后跟文字字符序列html
后跟一个可选组(因为它用括号括起来,后紧跟一个?
量词),该匹配项与一个问题匹配标记, m=
+一个或多个数字,然后跟在字符串标记的结尾。
Your expression does not work because you use a negative lookahead that is not supported by the RE2regex library that Google Analytics is using. 您的表达式无效,因为您使用的是Google Analytics(分析)RE2regex库不支持的否定前瞻。
Note : to test your expressions in GA you can use Google utilities when you create the view. 注意 :要在GA中测试您的表达式,可以在创建视图时使用Google实用程序。 Please read these instructions .
请阅读这些说明 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.