python - Regex Match for Domain Name in Django Model -
i have 1 table, looks like:
class tld(models.model):     domainnm = models.charfield(validators=[ regexvalidator('^[0-9]^[a-z]','yourdomain.com only','invalid entry')], max_length=40)     dtcreated = models.datefield()   for domainnm - want validate on entry looks like:
- domain.com
 - 1domain.com
 - domain1.com
 
it has follow way : <domainname>.[com|biz|net] etc , alphanumeric.
how do on model level of django model?
thanks
to recap clarifications above: want match domains single alphanumeric label , tld of 4 characters, eg. "domain.com" or "someotherdomain.info" or "345xyz.pdq1" not "subdomain.domain.com", "http://domain.com", "www.domain.com", or "345xyz.abcde". regex it:
^[a-z0-9]+\.[a-z0-9]{1,4}$      
Comments
Post a Comment