RegEx (17) - 使用字元 \S
阿新 • • 發佈:2021-01-16
使用python來做正則表示式:
import re
txt = "wer wer xfs wer"
#Return a match at every NON white-space character:
x = re.findall("\S", txt)
print('使用大寫字母\S結果:',x)
if x:
print("Yes, there is at least one match!")
else:
print("No match" )
txt_new = 'wer wer xfs wer'
#Return a match at every white-space character:
y = re.findall('\s', txt_new)
print('使用小寫字母\s結果:',y)
字元 \S: Returns a match where the string DOES NOT contain a white space character
結果如下:
如果覺得不錯,就點贊或者關注或者留言~
謝謝~