Regular expression for a string containing one word but not another

后端 未结 4 2050
孤独总比滥情好
孤独总比滥情好 2020-11-22 02:27

I\'m setting up some goals in Google Analytics and could use a little regex help.

Lets say I have 4 URLs

http://www.anydotcom.com/test/search.cfm?met         


        
4条回答
  •  不要未来只要你来
    2020-11-22 02:56

    This should do it:

    ^(?!.*details\.cfm).*selector=size.*$
    

    ^.*selector=size.*$ should be clear enough. The first bit, (?!.*details.cfm) is a negative look-ahead: before matching the string it checks the string does not contain "details.cfm" (with any number of characters before it).

提交回复
热议问题