Mixpanel Community Icon

Extracting Numbers from String in Mixpanel Custom Property

·
·

In mixpanel custom property, how can I extract 33 from ["33 Min"] string

  • Avatar of kapa.ai
    kapa.ai
    APP
    ·
    ·

    Hi Paritosh d., Please stand by as I search the Mixpanel knowledge base for an AI-powered answer. I normally take about 15 seconds or so. In case AI cannot answer your question, feel free to reach out to Mixpanel support at mixpanel.com/get-support. If you have follow-up questions for this thread, please tag me again with your question: @kapa.ai <follow-up question> đź‘‹

    Feel free to ask a follow-up question once I've answered by mentioning me with @kapa.ai

  • Avatar of kapa.ai
    kapa.ai
    APP
    ·
    ·

    To extract "33" from the string "["33 Min"]" in a Mixpanel custom property, you can use a combination of the regex_extract function and the number function. Here's how you can do it:LBKSnumber(regex_extract(properties["Your Property Name"], "\\d+", 0))LBKSLet's break down this formula:1. regex_extract: This function extracts a portion of a string based on a regular expression pattern. In this case, \\d+ matches one or more digits.2. number: This function casts the extracted string to a number.Here's what each part does:- properties["Your Property Name"]: This refers to your specific property that contains the "["33 Min"]" string. - "\\d+": This is the regular expression pattern that matches one or more digits. - 0: This argument in regex_extract specifies that we want the entire match (not a specific capture group).The regex_extract function will extract "33" as a string, and then the number function will convert it to a numeric value.This approach is based on the information provided in the Custom Properties Functions documentation, which describes the regex_extract function and its usage.Remember to replace "Your Property Name" with the actual name of your property that contains the "["33 Min"]" string.

    kapa.ai is still learning and improving, please let me know how I did by reacting below.

    ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.