Regex validate URL if it does not contain a subdomain : Basically, I would like to check a valid URL that does not have subdomain on it. I can't seem to figure out the correct regex for it.

Example of URLs that SHOULD match:

* example.com
* www.example.com
* example.co.uk
* example.com/page
* example.com?key=value

Example of URLs that SHOULD NOT match:

* test.example.com
* sub.test.example.com