首页 > 解决方案 > 谷歌事件的正则表达式

问题描述

您好,我想帮助编写一个正则表达式来捕获所有带有单词确认的网址。

例如: https ://example.com/this-is-a-confirmation

https://example.com/confirmation

https://example.com/folder/this-is-confirmation

我正在尝试设置一个目标,以捕获对网站上任何确认页面的所有访问,因为通过访问该页面,您很可能填写了表格以下载资产

谢谢!

标签: regex-group

解决方案


那么,基本上所有链接都以确认结束?

然后你可以使用一个非常愚蠢和简单的正则表达式,比如:

confirmation$

如果您只希望 URL 包含确认:

confirmation

已经足够了(Demo)。String.endsWith(str)这与您使用and基本相同String.contains(str)

根据您评估的方式,您可能需要在搜索词之前允许字符产生完全匹配(不仅仅是部分匹配):

.*confirmation

或者

.*confirmation.*

如果您想在搜索词之后允许任何文本。


推荐阅读