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