How to make sure that the domain name match those 3 simple criterias :
- Ends with .com / .net
Must not start with
- http:// or https://
- http://www. or https://www.
I’ve managed to understand this part of the regex which correspond with the first criteria :
/.*(\.com|\.net)$/
But i have no idea how to achieve the 2 others conditions to make an unique regex.
Thanks for your help.
A regex solution is easy. Simply assert a negative lookahead at the start of the string like so: (With comments…)
Note that since:
http://www.is a subset of:http://, the expression for the optionalwww.is not necessary. Here is a shorter version:Simple regex to the rescue!