Beast mode for the substring_index

Options
Atieh
Atieh Member

I'm trying to extract the substring from an URL.

URL: www.ab.com/level1/level2

I'm looking taking the level2 out of URL. What is the beast mode formula I can use here?

I want to get: level2

Tagged:

Best Answer

  • GrantSmith
    GrantSmith Coach
    edited May 27 Answer ✓
    Options

    you can use SPLIT_PART (Beast Mode or Magic ETL formula tile) or REGEXP_REPLACE (Magic ETL formula tile only)

    SPLIT_PART(`url`, '/', 3)
    

    or

    REGEXP_REPLACE(`url`, '^(http://)?([^/]+/){2}([^/]+).*$', '$3')
    

    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**

Answers

  • GrantSmith
    GrantSmith Coach
    edited May 27 Answer ✓
    Options

    you can use SPLIT_PART (Beast Mode or Magic ETL formula tile) or REGEXP_REPLACE (Magic ETL formula tile only)

    SPLIT_PART(`url`, '/', 3)
    

    or

    REGEXP_REPLACE(`url`, '^(http://)?([^/]+/){2}([^/]+).*$', '$3')
    

    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**
  • Atieh
    Atieh Member
    Options

    Thanks so much! It worked