Regex to retrieve all URLs not containing specific string

我怕爱的太早我们不能终老 提交于 2019-12-25 02:56:42

问题


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!


回答1:


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=)


来源:https://stackoverflow.com/questions/15144664/regex-to-retrieve-all-urls-not-containing-specific-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!