Google bigquery zipcode模式的正则表达式?

Google bigquery zipcode模式的正则表达式?,google-bigquery,Google Bigquery,如何为zipcode模式编写正则表达式?我需要确保所有zipcodessample地址都是5位数字,但我的查询不起作用 with table1 as( select "123 6th St. Melbourne, FL 32904" as address union all select "71 Pilgrim Avenue, Chevy Chase, MD 20815" union all select "70 Bowman St. South Windsor, CT 06074" unio

如何为zipcode模式编写正则表达式?我需要确保所有zipcodessample地址都是5位数字,但我的查询不起作用

with table1 as(
select "123 6th St. Melbourne, FL 32904" as address union all
select "71 Pilgrim Avenue, Chevy Chase, MD 20815"  union all
select "70 Bowman St. South Windsor, CT 06074" union all
select "4 Goldfield Rd. Honolulu, HI 966815"  union all
select "44 Shirley Ave. West Chicago, IL 60185" union all
select "514 S. Magnolia St. Orlando, FL 32806 "
)
select address,regexp_contains("address",r"\s\d{5}$")check from table1

至少删除regexp_包含的地址周围的引号

select address, regexp_contains(address, r"\s\d{5}$") check from table1  
此外,您可能还想在regex末尾再次使用$


将r\b\d{5}\b视为一个选项

一个问题是您正在检查最后一个字符是否为数字,对于最后一个示例514 S.Magnolia St.Orlando,FL 32806,最后一个字符是空格。我对这个问题投了否决票,因为您没有解释运行此查询时会发生什么。