如何在 Python 正則表示式中使用萬用字元?


以下程式碼使用 Python regex .()點字元作為萬用字元,它表示除換行符之外的任何字元。

示例

import re
rex = re.compile('th.s')
l = "this, thus, just, then"
print rex.findall(l)

輸出

它給出了以下輸出

['this', 'thus']

更新於: 2020 年 2 月 20 日

2 千 + 次觀看

開啟你的職業生涯

完成課程獲得認證

開始
廣告