简体   繁体   English

如何将正则表达式用于“包含此词”

[英]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=.)?(?!..) 

http://goo.gl/9LjV9P http://goo.gl/9LjV9P

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.

相关问题 如何将正则表达式用于“包含此词” - How can I use regex for “contains this word” 如何在正则表达式中匹配包含3个或更多数字的单词? - How can I match a word that contains 3 or more numbers in regex? 正则表达式POSIX - 我如何找到一行的开头是否包含一行中出现的单词 - Regex POSIX - How can i find if the start of a line contains a word from a word that appears later in line 我如何使用正则表达式来实现包含功能? - How I can use regex to implement contains functionality? 如何使用grep和regex匹配特定长度的单词? - How can I use grep and regex to match a word with specific length? 如何将可选单词与RegEx匹配,而不使用反向引用? - How can I match an optional word with RegEx and not use backreferences? 如何使用正则表达式在Python中搜索字符串中的重复单词? - How can I use regex to search for repeating word in a string in Python? 如何在 findstr 实用程序中使用单词边界正则表达式 - How can I use a word boundary regex in the findstr utility 如何在丹麦文字中使用“边界正则表达式”一词? - How can I use the word boundary regex with Danish literals? 如何使用正则表达式匹配包含至少一个大写字母但并非全部为小写的特定单词? - How do I use regex to match a specific word that contains at least one uppercase letter but not all in lowercase?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM