1234567891011121314151617181920212223242526272829 |
- # -*- coding: utf-8 -*-
- #!/usr/bin/env python
- import re
- NAME_RE = re.compile(ur'^[\u4e00-\u9fa5a-zA-Z0-9·]{2,20}$')
- PASSWORD_RE = re.compile(r'[A-Za-z0-9@#$%^&+=]{6,}')
- PHONE_NUMBER_RE = re.compile(r'^(1\d[\d]{9}$)|((400|800)-?(\d{3})-?(\d{4}))|(0\d{9,10})$')
- CARD_NO_RE = re.compile(r"[A-z\d]{1,32}$")
- def check_phone_number(phone, allow_null = False):
- if allow_null and not phone:
- return True
- if not phone:
- return False
- return PHONE_NUMBER_RE.match(phone)
- def check_entity_name(name, allow_null = False):
- if not name and allow_null:
- return True
- if not name:
- return False
- return NAME_RE.match(name)
|