Extracting data using regexp_extract in Google BigQuery

放肆的年华 提交于 2019-12-01 07:36:33

问题


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})') 

**

  • Input:-

**

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   

**

  • Output :-

** **

5e3152eafc50ed0346df7f10095d07c4
5e3152eafc50ed0346df7f10095d07c4

**


回答1:


It's very simple to do:

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

or as example:

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


来源:https://stackoverflow.com/questions/30333484/extracting-data-using-regexp-extract-in-google-bigquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!