正则表达式来检索所有不包含特定字符串的URL [英] Regex to retrieve all URLs not containing specific string

查看:577
本文介绍了正则表达式来检索所有不包含特定字符串的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Google Analytics(分析)PHP API,并尝试使用它来检索我网站上最受欢迎的链接。

它可以工作,但它会检索一些重复项由于它检索包含查询字符串的URL。所以基本上,我想检索所有不包含字符串?start =的链接。我认为这可以通过正则表达式来完成(谷歌分析接受正则表达式过滤器),但不知道如何。



有什么想法?



谢谢!

解决方案

您可以使用负面展望正则表达式断言。

请参阅 http://www.perlmonks.org/?node_id=518444 http://www.regular-expressions.info/lookaround.html

  your_string(?!\?start =)


I am using the Google Analytics PHP API, and trying to use it to retrieve the most popular links on my website.

It works, but it retrieve some duplicates due to it retrieving URLs containing query strings. So basically, I want to retrieve all the links which do not contain the string "?start=" inside them. I think this can be done via regex (Google Analytics accepts regex filters), but don't know how.

Any ideas?

Thanks!

解决方案

You can use negative look ahead regex assertion.

See http://www.perlmonks.org/?node_id=518444 and http://www.regular-expressions.info/lookaround.html

your_string(?!\?start=)

这篇关于正则表达式来检索所有不包含特定字符串的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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