1. 程式人生 > 其它 >RegEx (17) - 使用字元 \S

RegEx (17) - 使用字元 \S

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

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

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