1. 程式人生 > 其它 >RegEx (15) - 使用字元 \D 不包含數字

RegEx (15) - 使用字元 \D 不包含數字

技術標籤:RegExpython正則表示式regex

使用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

結果如下:
在這裡插入圖片描述
如果覺得不錯,就點贊或者關注或者留言~
謝謝~