I'm trying to create a regex that will optionally match any subdomains, and match the TLD. For example, it should match…
- https://example.com
- http://example.com
- https://test.example.com
- test.example.com
- example.com
It should not match…
- fakeexample.com
- https://fakeexample.com
- fake.fakeexample.com
I have this so far, which matches subdomains, but does not match when at the top level domain.
(\A|(https?:\/\/))?(\w*|\S*)\.{1}example\.com
foo.de
, and it's communications department is using the domaincom
and has a server calledexample
, then the DNS query forexample.com
will actually return the address ofexample.com.foo.de.
. – Jörg W Mittag