【发布时间】:2020-12-07 20:14:31
【问题描述】:
我有一堆地址,它们看起来不太相似。例如,我可以有
STREET NAME 12501 -ADP 11 LT P 1 -A , PS 1 Y ZOC
或
av some avenue 5640 j aguirre conchali
通常,字符串以街道名称开头,后跟其编号。如何获取第一个数字之前的所有字符,但包括数字?
例如:
av some avenue 5640 j aguirre conchali --> av some avenue 5640
STREET NAME 12501 -ADP 11 LT P 1 -A , PS 1 Y ZOC --> STREET NAME 12501
pje. 27 de abril 5492 --> pje. 27 de abril 5492 (in this case, the street name corresponds to the date April 27th)
1 poniente 643, valparaiso --> 1 poniente 643 (in this case, the street name is "1 poniente")
我正在尝试在BigQuery 中使用REGEXP_EXTRACT 执行此操作,但目前没有取得很大成功。
【问题讨论】:
-
您需要为每种格式定义一个正则表达式并使用布尔分隔符来创建一个大的
OR语句,如format1|format2|format3|format4 -
但这仍在使用
REGEXP_EXTRACT还是我应该切换到REGEXP_CONTAINS并在REGEXP_CONTAINS为真的地方执行REGEXP_EXTRACT?而且这种方法表明每种格式应该使用不同的列?
标签: regex google-bigquery