Add a more robust regular expression for API services.

This reduces the code complexity somewhat, at the expense of a
harder-to-read expression and a dependence on specific domains.