Firstly sorry for the 10,000th RegEx question,
I realise there are other domain related questions but the regex is either not working properly, too complex, or for urls with subdomains, protocols, and filepaths.
Mine is more simple, I need to validate a domain name:
google.com
stackoverflow.com
So a domain in its rawest form - not even a subdomain like www.
- Characters should only be a-z | A-Z | 0-9 and period(.) and dash(-)
- The domain name part should not start or end with dash (-) (e.g. -google-.com)
- The domain name part should be between 1 and 63 characters long
The extension (TLD) can be anything under #1 rules for now, I may validate them against a list later, it should be 1 or more characters though
Edit: TLD is apparently 2-6 chars as it stands
no. 4 revised: TLD should actually be labelled "subdomain" as it should include things like .co.uk -- I would imagine the only validation possible (apart from checking against a list) would be 'after the first dot there should be one or more characters under rules #1
Thanks very much, believe me I did try!