I need help in extracting the following string. I have tried many solutions but this one is the closest. But still not what I require. Any help is appreciated.
Sample URL: 'https://mywebsite/path/?utm_source=google&utm_medium=cpc&gclid=123abc'
Required Result:
| utm_source | utm_medium | gclid |
|---|---|---|
| cpc | 123abc |
The following example for gclid gives me gclid=123abc as a result, while I require to extract 123abc
SELECT l.url, REGEXP_SUBSTR(l.url, 'gclid=([^&]*)') as data
FROM mydatabase.mytable AS l
WHERE Date(l.registration_date) >= '2021-06-15'
AND REGEXP_SUBSTR(l.url, 'gclid=([^&]*)') is not null
I need to parse the other two fields also like utm_source and utm_medium.
REGEXP_SUBSTR(l.url, '(?<=[?&]gclid=)[^&#]+')and similarlyREGEXP_SUBSTR(l.url, '(?<=[?&]utm_source=)[^&#]+')andREGEXP_SUBSTR(l.url, '(?<=[?&]utm_medium=)[^&#]+')gclid=12345in sample URL butgclid=123abcin required output. Typo?