【发布时间】:2018-03-05 16:59:09
【问题描述】:
我正在努力获得用于对纬度和经度范围进行分组的正确正则表达式。我正在使用我相信使用 re2 的 Google Data Studio 过滤器。这些在 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]))
我知道 Data Studio 正则表达式可以使用管道/或符号,但我确实需要 &/and 符号来完成这项工作,但我认为我不能使用该符号。
我尝试了很多不同的组合,但我无法在 Data Studio 过滤器中完全正确。感谢您的帮助。
【问题讨论】:
-
你能举一个输入格式的例子吗?
-
当然,这是我正在尝试分组的 URL 标题(按页面标题过滤)的示例,等待纬度/经度。 “预测纬度 42.36(度符号)N 和经度 122.95(度符号)W”。谢谢!
标签: regex google-data-studio re2