Google BigQuery possible to do Case-Insensitive REGEXP_Match?

本秂侑毒 提交于 2021-02-07 13:45:39

问题


In Google BigQuery I wanted to check for 'confirm' or 'Confirm':

REGEXP_CONTAINS(h.page.PagePath, r'Confirm') or
REGEXP_CONTAINS(h.page.PagePath, r'confirm'))

I am a Perl person and in Perl we do

$foo =~ /confirm/i    # case-insensitive

Does Google BigQuery have any flags to modify REGEXP_MATCH? I did not see any examples in their online docs.


回答1:


REGEXP_CONTAINS uses RE2 library, so you may use inline modifiers like this:

REGEXP_CONTAINS(h.page.PagePath, r'(?i)confirm') 
                                   ^^^^  

See RE2 docs:

(?flags)    set flags within current group; non-capturing ...
                                                                Flags
i  case-insensitive (default false)
m  multi-line mode: ^ and $ match begin/end line in addition to begin/end text (default false)
s  let . match \n (default false)
U  ungreedy: swap meaning of x* and x*?, x+ and x+?, etc (default false)

Flag syntax is xyz (set) or -xyz (clear) or xy-z (set xy, clear z).



来源:https://stackoverflow.com/questions/42987537/google-bigquery-possible-to-do-case-insensitive-regexp-match

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