I have registration form where users can register their accounts with subdomain i.e. .mysite.com
Allowed things are,
abc.mysite.com
abc-def.mysite.com
abc123.mysite.com
abc_def.mysite.com
Not allowed,
http://abc.com.mysite.com
http://abc.mysite.com
www.abc.mysite.com
abc.def.mysite.com
abc.com.mysite.com
or any thing which is not a valid subdomain
if the users are going to input only the subdomain prefix, regexp would be something like
[A-Za-z-_0-9]+
and if do not wish to allow it becoming with http://www., then:
(?!www.)[A-Za-z0-9-_]+
and if you also do not wish to allow it end with .com, then:
(?!www.)[A-Za-z0-9-_]+(?!.com)