目标字符s='''!interfaceFastEthernet0/46!interfaceFastEthernet0/47switchportaccessvlan221switchportmodeaccessspanning-treeportfast!interfaceFastEthernet0/48switchportacces...
目标字符
s = '''!
interface FastEthernet0/46
!
interface FastEthernet0/47
switchport access vlan 221
switchport mode access
spanning-tree portfast
!
interface FastEthernet0/48
switchport access vlan 220
switchport mode access
dot1x port-control auto
spanning-tree portfast
!
interface GigabitEthernet0/1
switchport trunk encapsulation dot1q
switchport mode trunk
!'''
p = '(?:interface\s)((?:\w+)+\d+(?:/\d+)*)(?:\n\sswitchport\s)?([a|t]\w+)?(?:\s\w+\s)?(\d+)?(?:\n)?(?:.+\n)?\s?(dot1x)?'
re.findall(p,s)
输出结果是&#x