regexurltestingtargetingoptimizely

Targeting seperate parts of a URL in Optimizely with REGEX


I'm trying to target a set of URLs sharing the same template in Optimizely the https://chillisauce.com/hen/in-dublin/day

Specifically trying to target the hen/in- part and the /day part.

I've been testing this: /(hen)/in-.*/day[^/]+$

Although when testing the URL pattern in Optimizely it does not match.

Any ideas?

Thanks in advance

Charlie


Solution

  • Looks like Optimizely uses js regexes, so this should work:

    \/(hen)\/in-.+\/day[^/]*$
    

    See it in action here (allows you test on the fly modifications a little easier than optimizely's interface): https://regex101.com/r/9Np4Oj/2

    And you may want to consider following your later pattern ([^/]) here too.

    \/(hen)\/in-[^/]+\/day[^/]*$