问题
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 ...
Flagsi
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 ofx*
andx*?
,x+
andx+?
, etc (default false)
Flag syntax isxyz
(set) or-xyz
(clear) orxy-z
(setxy
, clearz
).
来源:https://stackoverflow.com/questions/42987537/google-bigquery-possible-to-do-case-insensitive-regexp-match