如何在 Python 正則表示式中使用萬用字元?
以下程式碼使用 Python regex .()點字元作為萬用字元,它表示除換行符之外的任何字元。
示例
import re
rex = re.compile('th.s')
l = "this, thus, just, then"
print rex.findall(l)輸出
它給出了以下輸出
['this', 'thus']
廣告
以下程式碼使用 Python regex .()點字元作為萬用字元,它表示除換行符之外的任何字元。
import re
rex = re.compile('th.s')
l = "this, thus, just, then"
print rex.findall(l)它給出了以下輸出
['this', 'thus']