是否有任何全面的正则表达式可以从一个单词中识别出所有类型的特殊字符,或者换句话说,我需要一个用于python的正则表达式,它将识别除字母(az或AZ)和数字之外的任何字符( 0-9)。
答案 0 :(得分:0)
试试这个:
if re.search("[^a-z0-9]", string, re.IGNORECASE):
# Successful match
else:
# Match attempt fail
说明:
[^a-z0-9]
---------
Options: Case insensitive;
Match any single character NOT present in the list below «[^a-z0-9]»
A character in the range between “a” and “z” (case insensitive for A-Z) «a-z»
A character in the range between “0” and “9” «0-9»