Regex to match 2 level deep URL and not 3 level deep (Google Analytics)

前端 未结 2 587
难免孤独
难免孤独 2020-12-18 03:40

I\'m trying to create content groups in Google Analytics. How do I match a page with sport/[SOMETHING] and not sport/[SOMETHING]/[SOMETHING]

Match:

  • /s
2条回答
  •  鱼传尺愫
    2020-12-18 04:32

    This worked for me ^\/sports\/([^\/]+)\/$

    Explanation: ^/sports/ => category to match with / escaped using \

    ([^/]+) => the not / once or more

    /$ => the closing first level page depth / with a $ stop

提交回复
热议问题