在 Google BigQuery 中使用 regexp_extract 提取数据 [英] Extracting data using regexp_extract in Google BigQuery

查看:31
本文介绍了在 Google BigQuery 中使用 regexp_extract 提取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从具有多个字符的列中提取数据,我只对从输入字符串中获取特定字符串感兴趣.我的示例输入和输出如下.我如何使用 regexp_extract 函数来实现这一点.如果你在 GBQ 上工作过,有人可以分享他们对此的想法吗?谢谢.

I am trying to extract data from a column which has multiple characters and I am only interested in getting the specific string from the input string. My sample input and outputs are as below. How can I implement this using regexp_extract function.Can someone share their thoughts on this if you have worked on GBQ.Thanks.

**

  • SQL:-

**

   SELECT request.url AS url 
    FROM [xyz.abc]
    WHERE regexp_extract(input,r'he=(.{32})') 

**

  • 输入:-

**

http://mpp.xyz.com/conv/v=5;m=1;t=16901;ts=20150516234355;he=5e3152eafc50ed0346df7f10095d07c4;catname=Horoscope  
2   http://mpp.xyz.com/conv/v=5;m=1;t=16901;ts=20150516234335;he=5e3152eafc50ed0346df7f10095d07c4;catname=High+Speed+Internet   

**

  • 输出:-

****

5e3152eafc50ed0346df7f10095d07c4
5e3152eafc50ed0346df7f10095d07c4

**

推荐答案

做起来很简单:

select regexp_extract(input,r'he=(.{32})');

或例如:

select regexp_extract('http://mpp.xyz.com/conv/v=5;m=1;t=16901;ts=20150516234355;he=5e3152eafc50ed0346df7f10095d07c4;catname=Horoscope',r'he=(.{32})')

这篇关于在 Google BigQuery 中使用 regexp_extract 提取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆