使用Google Analytics(分析)URL进行大查询Regexp_Extract

时间:2018-07-14 00:08:53

标签: google-bigquery

如何使用Big Query // Share on WhatsApp only, if installed (Android only) if( NativeShare.TargetExists( "com.whatsapp" ) ) new NativeShare().AddFile( filePath ).SetText( "Hello world!" ).SetTarget( "com.whatsapp" ).Share(); 提取下面的id参数,其中某些行中的页面网址类似于: url.com/id=userIDmadeUPofletterandnumbers&em=MemberType 例如url.com/id=asd1221231sf&em=studentMember

我尝试使用: 一种。 Regexp_Extract作为Idvalue,但收到错误消息:  无效的字符串文字:“ id = \ w +”

我与此非常接近:REGEXP_EXTRACT(urlValue,“(id =。*&em)”)但是它向我显示REGEXP_EXTRACT(urlValue,"id=\w+"),并且我想在末尾排除id=asd1221231sf&em和&em

1 个答案:

答案 0 :(得分:2)

   
#standardSQL
WITH `project.dataset.table` AS (
  SELECT 'url.com/id=userIDmadeUPofletterandnumbers&em=MemberType' urlValue UNION ALL
  SELECT 'url.com/id=asd1221231sf&em=studentMember'
)
SELECT REGEXP_EXTRACT(urlValue, r'id=(\w+)') id, urlValue
FROM `project.dataset.table`

Row id                              urlValue     
1   userIDmadeUPofletterandnumbers  url.com/id=userIDmadeUPofletterandnumbers&em=MemberType  
2   asd1221231sf      url.com/id=asd1221231sf&em=studentMember