Overpass API – Using Overpass QL for Multiple Values Without Union

overpass-api

When querying a parameter and one wants one of multiple values, is there a way to do it with an or statement?

I've found that the union statement works (as below)

(
  rel({{bbox}})[route="road"];
  rel({{bbox}})[route="bicycle"];
);

But this would seem quite inefficient when I have more values in the future. I was hoping the vertical line operator would do the trick but it doesn't seem to be.

(
  rel({{bbox}})[route="road|bicycle"];
);

Any way to do this in one query without the union?

Best Answer

A value match by regular expression can be used to achieve this without multiple statements in a union:

 rel({{bbox}})[route~"^(road|bicycle)$"];