import re def is_upc(value, display=False): value = str(value).strip().lstrip('0').replace(chr(160), "").replace("-", "") if display: match = re.match(r'\A(\d{9,14})\Z', value, re.I) else: match = re.match(r'\A(\d{9,13})\Z', value, re.I) return bool(match) def is_isrc(value): value = str(value).strip().replace(chr(160), "").replace("-", "") match = re.match( r'^[A-Za-z]{2}[-]?[0-9A-Za-z]{3}[-]?[0-9]{2}[-]?[0-9]{5}$', value, re.I) return bool(match)