Python regex to determine whether a character is numeric, alphanumeric or in a specified string -


i unsure how 1 use python regex determine whether character numeric, alphanumeric or in specified string.

something (fake code warning):

if 'a' in re.['a-z']:    print "alpha"  if '.' in re.['.,;']:    print "punctiation" 

you can use match function module re:

import re  x = 'a' if re.match('[a-za-z]', x):     print "alpha" 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -