I suggest using a simple approach, essentially building on what you said, just anything with a dot in it, but working with the forward slashes too. To capture everything and not miss unusual URLs. So something like:
^((?:https?://)?[^./]+(?:.[^./]+)+(?:/.*)?)$
It reads as:
- optional http:// or https://
- non-dot-or-forward-slash characters
- one or more sets of a dot followed by non-dot-or-forward-slash characters
- optional forward slash and anything after it
Capturing the whole thing to the first grouping.
It would match, for example:
nic.uk
nic.uk/
http://nic.uk
http://nic.uk/
https://example.com/test/?a=bcd
Verifying they are valid URLs is another story! It would also match:
It would not match:
The minimal match is basically something.something
, with no forward slash in it, unless it comes at least one character past the dot. So just be sure not to use that format for anything else.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…