python - regex to check if a number exists in a string -
i have list. want check if contains number
list1 = [u'studied @ ', u'south city college, kolkata', u'class of 2012', u'lives in ', u'calcutta, india', u'from ', u'calcutta, india'] >>> if re.match(r'[\w-]+$', str(list1)): print "contains number" else: print "does not contain number"
it not contain number. need help. want output "2012"
just re.search
pattern \d
. don't re.match
, matches start of string.
Comments
Post a Comment