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

问题描述

我试图从具有多个字符的列提取数据,我只想从输入字符串获取特定字符串。我的示例输入和输出如下。如何使用regexp_extract函数来实现这个功能。如果您曾参与过GBQ.Chan,可以分享他们对此的看法。

**




  • 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'他=(。{32})')


    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
    

    **

    解决方案

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

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

09-12 16:02