Matching multiple URLs with a wildcard top-level domain?

I’m working on an add-on and I need to be able to filter a website request from a website, regardless of the top-level domain (TLD) that it’s using. For example, I want to be able to match and and with a single matching filter instead of having to add a filter for each TLD.

Is it possible to use a wildcard for the TLD of a filter? Something like https://example.* or along those lines.

If not, is there a better alternative other than adding every possible variation to the filter array or matching all traffic and then manually processing the URL?

As far as I know the best way is to programmatically deal with it, similar to for example.