Overpass regulärer Ausdruck

Ich suche alle Öffnungszeiten die mit “+ close” enden.

  • ist ein Sonderzeichen. Daher habe ich es mit einem Backslash versehen. Doch mit

    [“opening_hours”~“+ closed$”]

    bekomme ich die Fehlermeldung
    static error: Invalid regular expression: “+ closed$”

Wenn ich den Backslash entferne bekomme ich immer noch die Fehlermeldung
static error: Invalid regular expression: “+ closed$”

Wie müsste der Ausdruck richtig lauten?

Doppelt escapen:

[out:xml][timeout:120];

nwr["opening_hours"~"\\+ closed$"]({{bbox}});  

out geom;

siehe overpass turbo

2 Likes

Genau, einmal für den regulären Ausdruck und dann nochmal für die QL:

Please note that in QL you need to escape backslashes: ["name"~"^St\."] results in the regular expression ^St. (which finds every name starting with “St”), while ["name"~"^St\\."] produces the most likely meant regular expression St\. (which finds every name starting with “St.”). This is due to the C escaping rules and doesn’t apply to the XML syntax.

Quelle: https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#Value_matches_regular_expression_(~,_!~)

2 Likes

Sieht :dizzy_face: aus. Man kommt auch ohne Escäpaden aus mit

A bracket expression. Matches a single character that is contained within the brackets. For example, [abc] matches “a”, “b”, or “c”
(Quelle: Wikipedia “Regular_expression”)

und [+] matscht genau ein “+”:

[out:xml][timeout:120];

nwr["opening_hours"~"[+] closed$"]({{bbox}});  

out geom;

Das liest sich für reguläre Expressionisten doch etwas angenehmer :wink:

4 Likes