I am unsure as to how one would use a Python regex to determine whether a character is numeric, alphanumeric or in a specified string.
Something like (fake code warning):
if 'a' in re.['A-Z']:
print "Alpha"
if '.' in re.['.,;']:
print "Punctiation"
Use str.isalpha()
method:
>>> 'a'.isalpha()
True
For testing single character for punctuation or alphanumeric, you can use constants pre-defined in string
module:
>>> '.' in string.punctuation:
True
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.