4

I have a phpBB forum and I want to merge the different urls Google Analytics throws up into 1, eg:

 /forum/viewtopic.php?f=16&t=6457
 /forum/viewtopic.php?t=6457
 /forum/viewtopic.php?f=16&t=6457&start=40

I'd like them all to point to

/forum/viewtopic.php?t=6457

I devised the following regEx filter:

Search and replace -> filter field: Request URI

Search string: \/forum\/viewtopic\.php\?f=([0-9]*)&t=[0-9]

Replace string: \/forum\/viewtopic\.php\?t=([0-9]+)$

It doesn't work, I am not sure what I am missing here. Any help?

migrated from webapps.stackexchange.com Sep 19 at 1:44

This question came from our site for power users of web applications.

  • 1
    The replace string can not be a regex again. Also when you do ?f=([0-9]*) it forces f= to be there, so your second URL will not match as it has ?t=6457. And when you do &t=[0-9] the [0-9] means a single character taken from the set of 0 to 9, so in your first URL &t=6457 won't match the regex as it has 4 characters, not one. You need [0-9]+ to match multiple digits. – Patrick Mevzek Sep 19 at 22:57
1

Search string: \/forum\/viewtopic\.php\?f=([0-9]*)&t=[0-9]

  • Replace f with [a-z] to capture any character between a and z.
  • + to capture one or more of the parameter (16 or 6457, etc..) but if you know the exact length of this string you can replace it with {1,5} for example.
  • capture everything after : .*

    \/forum\/viewtopic\.php\?([a-z]=([0-9]+)).*

If you provide more urls to capture I can edit and try to adjust the regex.

  • What I think I understand now is that a search and replace will not work, see eg. stackoverflow.com/questions/13742484/…. I am using an advanced filter to get rid of the f=. Field A \/forum\/viewtopic\.php\?(f=([0-9]+))(.*), Field B nothing, Output \/forum\/viewtopic\.php\?$A2 Not sure if it's going to work. If it does, I can use a second one to get rid of all that comes behind t=1234 – Caravanistan Sep 20 at 6:22
  • 1
    Changed Field A to \/forum\/viewtopic\.php\?(f=([0-9]+))&(t=([0-9]+))(.*) – Caravanistan Sep 20 at 7:14
1

Found the solution, with thanks to Patrick Mevzek and jpmg:

Filter type needed to be advanced, not search and replace.

Field A: \/forum\/viewtopic\.php\?(f=([0-9]+))&(t=([0-9]+))(.*)

Field B: -

Output: \/forum\/viewtopic\.php\?$A3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.