我是一个新的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'。 –