May I ask your help in order to build a regular expression to be used on Google Big Query using REGEXP_EXTRACT that will parse the value of an url parameter identified by a specific key?
Let's suppose that the parameter I would like to parse has key value equal to "source". The parsing should:
- Ensure that before the key there is "?" or a "&" and after there is a "=" : so in the example match "?source=" or "&source="
- Capture the value until the first "&" or end of string
- In case above conditions matches more than one time it should take the value of first occurance
Here are some example of desired behaviour (they should all provide "google" as output):
- www.google.com?source=google&medium=cpc --> output: google
- www.google.com?source=google --> output: google
- www.google.com?medium=cpc&source=google --> output: google
- www.google.com?medium=cpc&source=google&keyword=foo --> output: google
- www.google.com?medium=cpc&source=google&keyword=foo&source=bing --> output: google
- www.google.it?medium=cpc?source=goo-gle --> output: goo-gle
- www.google.it?medium=cpc?source=google?med=cpc&keyword=foo --> output: google?med=cpc
Thanks very much for any help!
