[英]Use Regex to match beginning and end part of URL in Google Analytics
I'm looking for a regex function to implement in a goal for Google Analytics. 我正在寻找要在Google Analytics(分析)目标中实现的正则表达式功能。
Consider this URL: /dagje-uit/....variable part..../contact/vpv/bedankt
考虑以下URL: /dagje-uit/....variable part..../contact/vpv/bedankt
Regex should work when beginning of URL matches /dagje-uit/
and end part contains /contact/vpv/bedankt
Everything in the middle can be variable. URL开头与/dagje-uit/
匹配并且末尾包含/contact/vpv/bedankt
时,正则表达式应该起作用。中间的所有内容都是可变的。
Without result i've tried 没有结果,我试过了
(?=^/dagje-uit/.*)(?=.*/bedankt$).*
(?=^dagje-uit.*)(?=.*bedankt$).*
Thanks in advance! 提前致谢! Regards, Pim 问候,Pim
Forgive me if Google Analytics has some regex standards which I am overlooking but is it possible that your regex is failing because it does not account for the start of the whole of the URL? 如果Google Analytics(分析)有一些我忽略的正则表达式标准,请原谅我,但是您的正则表达式是否有可能因为没有考虑到整个URL的开头而失败了? Adding .*
to either end of your regex may help. 在您的正则表达式的任何一端添加.*
可能会有所帮助。
It also looks like your regex is over-complex for the conditions you have described. 对于您描述的条件,您的正则表达式看起来过于复杂。 Could a simpler match be : 更简单的匹配可以是:
.*/dagje-uit/.*/contact/vpv/bedankt.*
or 要么
http(s)?://.*/dagje-uit/.*/contact/vpv/bedankt.*
if you want to be a little more confident that it is a valid URL. 如果您想更确定它是一个有效的URL。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.