[英]BigQuery regex to find string that contains chinese characters
我想找到包含任何中文字符的字符串。
我在 PostgreSQL 中有以下查詢,它按預期工作。
with tmp as (
select '中文zz' as word
union all
select '中文' as word
union all
select 'english' as word
union all
select 'にほんご' as word
union all
select 'eng–lish' as word
)
select word,
word ~* '[\x4e00-\x9fff\x3400-\x4dbf]'
from tmp
結果:
中文zz true
中文 true
english false
にほんご false
eng–lish false
但是,如果我在 BigQuery 中轉換這個 SQL,它不會產生相同的結果。
with tmp as (
select '中文zz' as word
union all
select '中文' as word
union all
select 'english' as word
union all
select 'にほんご' as word
union all
select 'eng–lish' as word
)
select word,
regexp_contains(word, r'[\x4e00-\x9fff\x3400-\x4dbf]')
from tmp
結果:
中文zz true
中文 false
english true
にほんご false
eng–lish true
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.