我是一個新的python用戶。編寫一些代碼以使用正則表達式匹配多行場景。但無法得到答案。任何人都可以幫助我,如果我失去了一些東西。python中多行代碼的正則表達式匹配
我試着在pythex.org
它,當我從代碼
a = """
MEG Type EntityId Level PrimVlan CC Inter(ms) CC Priority CC EnaStatus
---------- -------- -------- ----- -------- ------------ ----------- ------------
meg401 lsp 1 4 3 3.3 6 enable
MEP ID Type EntityId Level Intf RMEP ID Direction Active Status
---------- -------- -------- ----- ------- -------- --------- -------------
meg401 lsp 1 4 0/5 451 down disable
"""
result = re.match("meg401(.*)",a,re.M)
print result
它是失敗的嘗試被匹配所需的兩個lines.But。欣賞任何建議!
要匹配什麼呢? – Kasramvd
我想你想使用're.search'而不是're.match'。 –