简体   繁体   English

如何从 SQL bigquery 中的 URL 中提取 utm_content

[英]how to extract the utm_content from the URL in SQL bigquery

I'm trying to extract the utm_content from the URL.我正在尝试从 URL 中提取 utm_content。

For example:例如:

https:/www.xxxxxx.com/br/pt/yyyyy/example?origin=ALL&destination=ALL&utm_source=salesforce&utm_medium=email&utm_campaign=just_an_example_ok&utm_content= I_would_like_just_this_part_of_the_string https:/www.xxxxxx.com/br/pt/yyyyy/example?origin=ALL&destination=ALL&utm_source=salesforce&utm_medium=email&utm_campaign=just_an_example_ok&utm_content= I_would_like_just_this_part_of_the_string

¿How could I extract just the utm_content after the utm_content= ? ¿如何在utm_content=之后仅提取 utm_content ?

Generally, there is 12-13 fragments (splited by _) in my utm_content.通常,我的utm_content 中有12-13 个片段(以_ 分割)。

I would like to have this:我想要这个:

URL URL utm_content utm_content
https:/www.xxxxxx.com/br/pt/yyyyy/example?origin=ALL&destination=ALL&utm_source=salesforce&utm_medium=email&utm_campaign=just_an_example_ok&utm_content=I_would_like_just_this_part_of_the_string https:/www.xxxxxx.com/br/pt/yyyyy/example?origin=ALL&destination=ALL&utm_source=salesforce&utm_medium=email&utm_campaign=just_an_example_ok&utm_content=I_would_like_just_this_part_of_the_string I_would_like_just_this_part_of_the_string我_would_like_just_this_part_of_the_string

Any suggestions?有什么建议么?

See example below请参见下面的示例

select url, 
  regexp_extract(url, r'utm_source=([^&]+)') as utm_source,
  regexp_extract(url, r'utm_content=([^&]+)') as utm_content
from your_table         

if applied to sample data in your question - output is如果应用于您问题中的示例数据 - output 是

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM