问题
I'm creating a content grouping with the following URLs:
/my-category/something
/my-category/somethingelse
/my-category/product1-brand-color
/my-category/product2-brand-color
How to create a RegEx to group /my-category/ pages but exclude everything that has "brand"?
回答1:
Google Analytics doesn't support negative lookahead expressions. Instead, create 2 (or more) filters:
- The first filter to include your regex using the "Only Show" dropdown
- The second filter using the "Don't Show" dropdown containing your exclude rule
回答2:
More of a GA question than a Regex question. Regex is somewhat fussy to use in Google Analytics. Use GA's 'Advanced filter' option to include and exclude RegEx. You would get your result with either "containing" or "matching Regex" :
Include Page containing category Exclude Page containg brand
回答3:
Use a negative look-ahead.
To match /my-category/
only when it's not followed by -brand-
/my-category/(?!.*-brand-)
Or to match /my-category/
only when it's not followed by a dash (ie any brand):
/my-category/(?!.*-)
回答4:
I think you want something like this,
(?=^\/my-category)(?!.*?brand.*).*
DEMO
If you wanat this in a group then put open and close parenthesis in the pattern,
(?=^\/my-category)(?!.*?brand.*)(.*)
来源:https://stackoverflow.com/questions/24586893/google-analytics-regex-exclude-a-phrase