There is a tool called overpass, it's quite complex but for simple things like this it's pretty straightforward, here's a link to get you started: https://overpass-turbo.eu/s/1tjl. If you click export, you can load the results directly into JOSM to mass-edit the tags. If you have any questions, the #overpass channels on either the OSMUS Slack or OSM World Discord are pretty responsive, as well as https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_API_by_Example and https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL