Mixpanel Community Icon

Troubleshooting REGEX_EXTRACT Issues in Mixpanel Custom Properties

¡
¡

I continue to have problems with using REGEX_EXTRACT in custom properties... here's the regex that I built to strip away the trailing part of a url (you can see it working) and how I used it mixpanel, but something is clearly wrong; last time I had trouble with escaping characters properly, but this is valid PCRE, so if that's the case it means that Mixpanel is not, in fact, using PCRE?

  • Avatar of Andrew S.
    Andrew S.
    ¡
    ¡

    Vlad S. not sure what you mean when it's clearly wrong. What is it not doing? I have used this as a custom property to get the based domain without any parameters.

    REGEX_EXTRACT(@"""{"label":"Current URL","propertyDefaultType":"string","resourceType":"event","type":"string","value":"$current_url"}"""@,"[^?#]+",0)

    So the regex is [^?#]+

  • Avatar of Vlad S.
    Vlad S.
    ¡
    ¡

    how is it wrong? and if it's wrong, why does it work in regex101?

  • Avatar of Vlad S.
    Vlad S.
    ¡
    ¡

    to be clear, I expect the output to be the first part of the url (what's in the green in the first screenshot) but I just get (not set) in Mixpanel

  • Avatar of Andrew S.
    Andrew S.
    ¡
    ¡

    I'm not saying your Regex is wrong. I'm asking what is wrong about it. what is not working (can't tell from your images)

  • Avatar of Vlad S.
    Vlad S.
    ¡
    ¡

    ohhh... yeah, it just doesn't extract anything

  • Avatar of Andrew S.
    Andrew S.
    ¡
    ¡

    when I did this:

    REGEX_EXTRACT(@"""{"label":"Current URL","propertyDefaultType":"string","resourceType":"event","type":"string","value":"$current_url"}"""@,"(.*?)\/*([?].*)?",0)

    which I think is a copy of yours, I agree I get no results. But I think you are missing the ^ and the $ in what you put in.

    REGEX_EXTRACT(@"""{"label":"Current URL","propertyDefaultType":"string","resourceType":"event","type":"string","value":"$current_url"}"""@,"^(.*?)\/*([?].*)?$",1)

    that is returning results.

  • Avatar of Andrew S.
    Andrew S.
    ¡
    ¡
  • Avatar of Vlad S.
    Vlad S.
    ¡
    ¡

    🤦 thanks, let me give it a try!

  • Avatar of Vlad S.
    Vlad S.
    ¡
    ¡

    yep, user error 😞

  • Avatar of Vlad S.
    Vlad S.
    ¡
    ¡

    thank you!

  • Avatar of Andrew S.
    Andrew S.
    ¡
    ¡

    🤝