본문 바로가기

app/python

python regex special symbol identification example



if you want to string inner one or more special symbol charter


str = "qwe123!@#"


import re

p = re.compile('[^a-zA-Z0-9]+')

print bool(p.search(str))

-> True



if you want to string inner only special symbol charter


import re

p = re.compile('[a-zA-Z0-9]+')

if bool(p.search(str)) == False:

print "use only special symbol charter"