RegEx(16) - 使用字元 \s 找出空格位置
阿新 • • 發佈:2021-01-16
使用python來做正則表示式:
import re
txt = "sdf wer fsdf wer"
#Return a match at every white-space character:
x = re.findall("\s", txt)
print('x 結果:',x)
if x:
print("Yes, there is at least one white-space!")
else:
print("No match")
txt_new = '23423423sfsd23423'
y = re.findall('\s', txt_new)
print('y 結果:',y)
if y:
print('Yes, there is at least one white-space')
else:
print('No white-space')
字元 \s 的意思: Returns a match where the string contains a white space character
結果如下:
如果覺得不錯,就點贊或者關注或者留言~
謝謝~