正则表达式 re2 分组(和/或运算符)



我正在努力获得正确的正则表达式来对纬度和经度范围进行分组。我相信我正在使用使用 re2 的谷歌数据洞察过滤器。这些是在 URL 中给出的,所以我试图只过滤掉我感兴趣的不规则形状域中的纬度/纬度对。 如果它是一个方形域,我可以很容易地做到这一点,因为有一组 lat 对应于一组 lon。

以下是我想做的:

If latitude is in this range: Latitude 39.[4-9]|Latitude 40.[0-9]|Latitude 41.[0-5]  AND longitude is in this range: Longitude 80.[0-5]|Longitude 79.[0-9]  (then capture these URLs)

或者如果

latitude is in this range: Latitude 40.[0-7]|Latitude 39.[6-9] AND longitude in this range: Longitude 82.[2-9]|Longitude 81.[0-9]|Longitude 80.[0-5] (then capture these URLs)

以下是我应该能够做到这一点的感觉,但语法不起作用:

((Latitude 39.[4-9]|Latitude 40.[0-9]|Latitude 41.[0-5]) & (Longitude 80.[0-5]|Longitude 79.[0-9]))|((Latitude 40.[0-7]|Latitude 39.[6-9])&(Longitude 82.[2-9]|Longitude 81.[0-9]|Longitude 80.[0-5]))

我知道数据工作室正则表达式可以使用管道/或符号,但我真的需要 &/and 符号来完成这项工作,但我认为我不能使用该符号。

我尝试了很多不同的组合,但我在数据洞察筛选器中无法完全正确。感谢您的任何帮助。

我想

我想通了。我需要将纬度和经度合并到一个正则表达式中,然后使用 Google 的数据洞察选项使用"or",然后输入下一个表达式。

下面是两个表达式,它们通过 .{2,3} 部分。

.+for Latitude (39.[4-9]|40.[0-9]|41.[0-5]).{2,3} and Longitude (80.[0-5]|79.[0-9]).+
.+for Latitude (40.[0-7]|39.[6-9]).{2,3} and Longitude (82.[2-9]|81.[0-9]|80.[0-5]).+