Displaying 1 result from an estimated 1 matches for "regex_2".
Did you mean:
regex2
2011 Aug 03
0
[PATCH] update valid_hostname regex checks
...valid_hostname(hostname):
- regex = "^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])$"
- if re.match(regex, hostname):
+ regex_1 = "^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])\.)+([a-zA-Z0-9]{2,5})"
+ regex_2 = "^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])$"
+ if re.match(regex_1, hostname):
return True
else:
- return False
+ if re.match(regex_2, hostname):
+ return True
+ else:
+...