我正在努力为纬度和经度的分组范围获得正确的正则表达式。我正在使用Google Data Studio过滤器,我相信它使用的是re2。这些是在URL中给出的,所以我试图过滤掉我感兴趣的不规则形状的域中的经度/经度对。如果它是一个正方形区域,我可以很容易地做到这一点,因为有一组后一组对应于一组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 regex可以使用管道/或符号,但我真的需要&/和符号来使其工作,但我不认为我可以使用该符号。
我尝试了很多不同的组合,但在Data Studio筛选器中我不能完全理解。谢谢你的帮助。
发布于 2018-03-06 05:31:10
我想我想通了。我需要将纬度和经度组合到一个正则表达式中,然后使用Google的Data Studio选项来使用"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]).+
https://stackoverflow.com/questions/49115687
复制相似问题