Google Analytics Regex include and exclude string without negative lookahead

扶醉桌前 提交于 2019-12-11 11:32:11

问题


I'm trying to set up a Goal in Google Analytics using regular expressions to match urls that should contain the string "_thanks" but should not match urls that contain "-cl-" or "-wf-" or "-wl-".

This would be easier to do if Google Analytics would support negative lookahead, but unfortunately it doesn't.

For example the Goal should match:

/ba-ck-wp-example-of-a-page_thanks.html?ad=1073
/ba-default-page_thanks.html
/ba-nt-visit-some-page_thanks.html?ad=1731

But shouldn't match:

/ba-cl-a-free-quote_thanks.html
/ba-wf-information-report_thanks.html
/ba-wl-information-otherreport-example_thanks.html

Any help would be much appreciated.


回答1:


^(?:[^-]|-(?:[^cw].?|c[^l]|w[^fl])-|-.{2}[^-])*_thanks

As you can see, the complexity increases as the length of the words you don't want to match (in this case 4 characters) grows.



来源:https://stackoverflow.com/questions/34611892/google-analytics-regex-include-and-exclude-string-without-negative-lookahead

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