Overpass query example

Regular expressions on tag values

Match several values, parts of values and any case with ~ and ,i. Example: sushi and ramen places in Hamburg.

~ compares a tag with a regular expression instead of an exact value. Add ,i to ignore upper and lower case.

The query

[out:json][timeout:60];
area["name"="Hamburg"]["admin_level"="4"]->.a;
nwr["amenity"="restaurant"]["cuisine"~"sushi|japanese|ramen",i](area.a);
out center;

Run it

Running the query…

Live result from overpass.ch, cached for up to 12 hours. Map data © OpenStreetMap contributors (ODbL).

How it works

  1. sushi|japanese|ramen matches any of the three words anywhere in the value.
  2. ,i makes it case-insensitive.
  3. !~ is the negation: values that do not match.

Variations

  • Anchor with ^ and $ for exact matches: ^(pub|bar)$.
  • Regular expressions on keys: see fixme notes.

Run it from your code

curl https://api.overpass.ch/v1/YOUR_API_KEY/interpreter \
  --data-urlencode 'data@query.overpassql'

Save the query as query.overpassql. It works the same in Overpass Turbo, QGIS and JOSM.

More examples

All examples →