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.
    ·
    ·

    đŸ€

  • Avatar of Thena
    Thena
    APP
    ·
    ·

    Hi Vlad, My name's Scott and I'm a Support Engineer at Mixpanel — here to help. I'm sorry to hear about the trouble with the REGEX_EXTRACT feature. Diving right in, can you clarify which element or what text you want extracted from the Current URL property? If you could provide an example URL and the output you expect from the Regex, that would help me troubleshoot this further. I believe our Regex library should be PCRE compliant, so I will confirm that with our team. Thanks,Scott MarinoffSupport Engineer II --------------------💬  Liked my support? Please share your feedback in the survey you'll receive soon.

  • Avatar of Vlad S.
    Vlad S.
    ·
    ·

    in this particular case it was user error (see the thread)

  • Avatar of Vlad S.
    Vlad S.
    ·
    ·

    but the character escaping in mixpanel regex is not the same as in standard PCRE, i've posted about it before, I've had to trial and error with escape sequences in order to get my regexes to work, because they would work on regex101.com but not in mixpanel

  • Avatar of Andrew S.
    Andrew S.
    ·
    ·

    yeah, often have to "double escape" characters