Skip to content
Advertisement

Fetch Substring in Oracle

I have a string as –

V_TAG_B = utm_source=google_search&utm_medium=cpc&utm_term={Keyword}&utm_campaign=home-|-SBI-|-search

I need to break this string into 4 small parts as –

I need to do this because the string can be in any order such as utm_campaign coming first and utm_source is coming at last. So after breaking it into pieces i will concat it again and will match with our DB table in which a column have the same value as this string. I have achieved this using SUBSTR/INSTR combination as below –

I guess this can be shortly and easily achieved using REGEXP SUBSTR also. Any help/suggestion is appreciated.

Advertisement

Answer

You can use REGEXP_SUBSTR as following:

Cheers!!

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement