I need to create a regex that identify a string if that is a url with my criteria but i got stuck in identifying the domain name...
the criteria for domain name is
- only
[a-z][0-9],.and- - first char must be
[a-z] - before and after
.or-must be[a-z] - min length 1 char
and the domain region is
- only
[a-z]and. - first char must be
. - min length 3 char
format should be www.<domain name>.<domain region>
here what i got..
www.[a-z]([a-z0-9\.\-]{1,}[a-z][\.\-])+[^\.+\-].[a-z+\.]{2,}[^\.]$
this is for the domain name
[a-z]([a-z0-9\.\-]{1,}[a-z][\.\-])+[^\.+\-]
this is for the domain region
.[a-z+\.]{2,}[^\.]$
this will be www.sample.com.sg
www..sample.comwill be rejected because of.samplewww.sample..comwill be rejected because ofsample.www.sample.com.sg.will be rejected because of.com.sg.www.sampl3.sample.comwill be rejected because ofsampl3.rules numb 3.
www\.[a-z]([.-][a-z]|[a-z0-9])+all-4-one.com?