正确匹配RegEx; ^和$不完全分隔 [英] RegEx Matching exactly; ^ and $ not completely delimiting

查看:94
本文介绍了正确匹配RegEx; ^和$不完全分隔的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将Google Analytics中等效的/ mortgage /与Regex进行匹配,但是我仍然在第二个/和其他出现该术语的实例以及完全非



我试过了/按揭贷款/ $

$按揭$

\bmortgage\b

但是很大程度上我正在返回同一系列的数据....

解决方案

完全匹配/ mortgage /,使用:

  ^ \ / mortgage \ / $ 

若要匹配/ mortgage / some / other_stuff,请使用;

  ^ \ / mortgage\ /.* 

如果/ mortgage /位于字符串的起始位置,则匹配成功。



如果您试图仅查看/按揭/可以通过自定义报告来完成此操作在匹配正则表达式的页面上设置的过滤器

  ^ \ / mortgage \ / $ 


I'm trying to match the equivalent of EXACTLY "/mortgage/" in Google Analytics with Regex, however I'm still getting additional strings following the second "/" and other instances where the term appears as well as completely non-relevant terms.

I've tried

^\/mortgage\/$

^mortgage$

\bmortgage\b

But largely am being returned the same series of data....

解决方案

To match exactly "/mortgage/", use:

^\/mortgage\/$

To match "/mortgage/some/other_stuff", use;

^\/mortgage\/.*

In both cases, that match is successful iff "/mortgage/" is at the start of the string.

If you are trying to see visits to /mortgage/ only, then you could do this through Custom Reports, with a filter set on the Page which matches the regex

^\/mortgage\/$

这篇关于正确匹配RegEx; ^和$不完全分隔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆