With Overpass, how to exclude element with tag prefix?

Hi!

With Overpass, I want to get all elements that don’t have any tag with the “contact” prefix:
Elements with neither contact= nor contact:phone= nor contact:email= etc.

How to code that element tags should not match “contact.*”?

Thanks

Hello! Someone else may have a more efficient answer, but here’s what I could come up with.

I just query non-road/rail nodes and ways for examples sake, that could be anything. Then those coordinates are just a place I found with one building with a contact tag.

In this example, first everything goes into the result set “all”. Then I query “all” for anything that has a tag key that matches the regex “begins with: contact” (and has any value). The output of that gets stored in “exclude”. And then the final result is “all” minus “exlcude”.

[out:json][timeout:25];

nw[!"highway"][!"railway"](40.65456992932741,-73.96208492589557,40.65513398629673,-73.96027673770053)->.all;
nwr.all[~"^contact"~".*"]->.exclude;
(.all; - .exclude;);

out geom;