I need to validate a known domain, like domain.com with JavaScript, but I need to validate it with any subdomain or sub-subdomains and so, and with any protocol and with any folder, sub-folder, and so, I have this regular expression:
RegEx: /http:\/\/([\.|a-z]+).domain([\.|a-z]+)\//
The problem is it not gets https/ftp/ftps... and it get domain.com/domain.org... I need to validate, something like this:
To validate: *://*.domain.com/*
Example: http://example.domain.com/subfolder2/folder24/
Example: https://subdomain.domain.com/folder/
Example: ftp://www.example.domain.com/folder2/folder/
Example: http://www.domain.com/folder/sub-folder/
I mean, any protocol, any subdomain, and any folder, and of course, all of them together too:
Example: https://example.domain.com/folder/folder/
Any idea?
domain([\.|a-z]+)
withdomain\.com
.http
of course does not matchhttps
orftp
or the like. But you can use alternation to allow more protocols. – Felix Kling