a='''
interface 50|100GE2/0/0
port-speed 100GE
description [50|100GE2/0/0]-[100G]
undo shutdown
eth-trunk 100
undo dcn
#
'''
import re
b='50|100GE2/0/0'
interface_block_pattern = re.compile(r"(interface {}.*?#)".format(b),re.DOTALL)
interface_block_match = interface_block_pattern.search(a)
print(interface_block_match.group())
为啥输出的不是整个a,而是‘interface 50’
我python版本是3.11.5