RegEx (15) - 使用字元 \D 不包含數字
阿新 • • 發佈:2021-01-16
使用python來做正則表示式:
import re
txt = "wer DE ase 12"
#Return a match at every no-digit character:
x = re.findall("\D", txt)
print('x 的結果:',x)
if x:
print("Yes, there is at least one match no-digit character!")
else:
print("No match" )
txt_new = '23 234 2423 234'
y = re.findall("\D", txt_new)
print('y 的結果:',y)
text = '3432 24 234 2343 sdf'
z = re.findall('\D', text)
print('z 的結果:',z)
字元 \D: Returns a match where the string DOES NOT contain digits
結果如下:
如果覺得不錯,就點贊或者關注或者留言~
謝謝~