UPDATE: Fixed thanks to @Robin. It worked, but it was a little bit off from what I intended.
Assuming only http or https (and no ports), this works:
(https?://(?:\w+\.)+com)(?:/.*)?

Debuggex Demo
The url is in capture group one.
Explanation of (?:\w+\.)+
:
- One-or-more of
- one-or-more word-character: letter, digit, or underscore
- followed by a literal dot.
For example, this portion captures usatoday.
and entertainment.usatoday.
. All the pre-domain (.com
) portions of the url.
To be safe you could also add start- and end-of-line anchors:
^(https?://(?:\w+\.)+com)(?:/.*)?$
To add the possibility of different domains, add them like this:
^(https?://(?:\w+\.)+(?:com|net|org|gov))(?:/.*)?$
Note that this question, and its duplicate, will also be of help: regular expression for url