RegEx (23) - 使用字元[^ ] 來尋找除了括號裡的其他字元
阿新 • • 發佈:2021-01-17
使用python來做正則表示式:
import re
txt = "werew asdfs IIHHHLL 234"
#Check if the string has other characters than a, r, or n:
x = re.findall("[^arn]", txt)
print(x)
if x:
print("Yes, there is at least one match!")
else:
print("No match" )
字元[^arn]: Returns a match for any character EXCEPT a, r, and n
結果如下:
如果覺得不錯,就點贊或者關注或者留言~
謝謝~