【发布时间】:2021-06-29 01:32:08
【问题描述】:
您好,我正在尝试使用大查询提取 7digit 以提取 2670782 和 2670788 关于这个数据
描述下面的字段数据
is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type 8888888 specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing 8888888 software like Aldus PageMaker including versions of Lorem Ipsum.
>> https://hello.com/pudding/answer/2670782?hl=en&ref_topic=7072943
>> https://hello.com/pudding/answer/2670788?hl=en&ref_topic=7072943
我有一个查询,但除了 2670782 和 2670788 之外,数据上还有其他 7 位数字。所以首先我想检查该行是否以“>>”开头并包含“hello.com”,我可以提取它。
这是我的查询,但它也会获取不应该的 8888888。
SELECT
desc,
REGEXP_EXTRACT_ALL(desc, r"\/(\d{7})") AS num
FROM
`table`
WHERE
REGEXP_CONTAINS(DESCRIPTION, r"(>> )")
AND REGEXP_CONTAINS(desc, r"(hello.com)")
我相信我需要检查该行是否以 >> 开头,并且它在单个正则表达式中包含 hello.com,然后我可以提取 / 之后的 7 位数字。我被卡住了
任何帮助将不胜感激!
【问题讨论】:
-
我迷路了。样本数据是一行还是多行? “如果该行以 >> 开头”是什么意思?
-
在 KaBoom 的回答中尝试在正则表达式的开头添加
(:?m)以允许^匹配字符串的开头和换行符。
标签: regex google-bigquery