Regular Expression not working in Google Analytics, possibly due to Positive Lookahead?

て烟熏妆下的殇ゞ 提交于 2019-12-11 02:18:31

问题


I have a regular expression here which works perfectly in Regex101 (see demo). anubhava provided this solution in this question.

/^(?=.*\b[1-9]\b)(?=.*\b1[0-7]\b)[0-9]+(?:,[0-9]+)+$/gm

However, when I try to use it in Google Analytics, I get this warning - "Invalid regular expression. Your data request includes an invalid regular expression."

Do you know how I can get the same results, but satisfy Google Analytics security requirements, which seem to be disallowing lookaheads?


回答1:


((^|,)([0-9]|(1[0-7])))*((((^|,)[0-9](,[0-9]|(1[0-7]))*(,1[0-7])))|(((^|,)1[0-7]((,[0-9]|(1[0-7])))*(,[0-9]))))(,([0-9]|(1[0-7])))*$

Thanks to GA's extremely limited regex language, this is a pretty inefficient and gross regex, but it matches your use cases.

https://regex101.com/r/oN2jB0/8



来源:https://stackoverflow.com/questions/38229345/regular-expression-not-working-in-google-analytics-possibly-due-to-positive-loo

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