0

I have the following url:

pro.somecompany.com/#/aquisitionintelligence/competitiveanalysis/overview/website-performance/hospital.org/*/484/3m?webSource=Desktop

I want to the aquisitionintelligence part and the competitiveanalysis part

Also, sometimes I have links like so /#/insights/reports?types=SC

How do I get only the reports part?

any idea how to do it in SQL?

1
  • 1
    Please edit your question to provide more sample inputs, and what you are seeking as the output for each of those inputs. Commented Oct 13, 2020 at 10:40

1 Answer 1

1

You can use regexp_substr() for the general problem of a complex delimiter.

For the third part for instance:

select regexp_substr(col, '[^/?]+', 1, 3)

If you want just the third part using a single delimiter, use split_part():

select split_part(col, '/', 3)
Sign up to request clarification or add additional context in comments.

2 Comments

This works beautifully! Can you explain the special characters and structure? or refer me to a good source?
@nimi1234 . . . I referenced the documentation on the functions. The "special characters" are the delimiters. In the first case, they are characters not allowed in the returned value. In the second, it is just the delimiter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.