【发布时间】:2018-05-07 18:35:29
【问题描述】:
我有以下字符串
interface Vlan17
description ALU-VDSL-MGM
ip vrf forwarding Access-Mgmt
ip address 10.156.207.254 255.255.255.192
!
interface Vlan18
description name VDSL-VOIP
ip vrf forwarding IN_MEDIA_SIGNALING
ip address 20.11.64.1 255.255.240.0
ip helper-address 10.200.15.39
ip helper-address 10.208.10.199
!
interface Vlan24
description By NCM: Task ID 49899 - 24-0 -
no ip address
!
interface Vlan30
description By NCM: Task ID 149868 - HU-FTTH-MNG-HC111003OL05
ip vrf forwarding Access-Mgmt
ip address 10.155.225.214 255.255.255.248
no ip redirects
!
interface Vlan39
description ALU-NGN-MNG
ip vrf forwarding Access-Mgmt
ip address 10.202.23.252 255.255.255.0
!
interface Vlan58
description By NCM: Task ID 571151 - HU-NGN-MNG-395-32-000
ip vrf forwarding Access-Mgmt
ip address 10.143.21.254 255.255.255.240
no ip redirects
!
interface Vlan72
no ip address
shutdown
!
interface Vlan75
description By NCM: Task ID 536967 - Atheeb-VOIP
ip vrf forwarding Atheeb-VoIP
ip address 10.248.92.1 255.255.252.0
ip helper-address 172.16.89.22
ip helper-address 172.17.89.22
no ip redirects
no ip unreachables
no ip proxy-arp
!
interface Vlan78
description By NCM: Task ID 049989 - 78-0 -
no ip address
!
interface Vlan81
description By NCM: Task ID 4498508 - MW-Mgmt
ip vrf forwarding V3620:EBU-COMIS
ip address 10.153.207.193 255.255.255.224
!
interface Vlan82
description By NCM: Task ID 606871 - MDU-Mgmt
ip vrf forwarding V3620:EBU-COMIS
ip address 10.74.37.193 255.255.255.192 secondary
ip address 10.74.117.1 255.255.255.192
no ip redirects
!
interface Vlan83
description By NCM: Task ID 790456 - PtMP-Mgmt
ip vrf forwarding PtMP-Mgmt
ip address 10.73.3.78 255.255.255.248
no ip redirects
no ip unreachables
!
interface Vlan84
description By NCM: Task ID 1486 - PtMP-Mgmt
ip vrf forwarding PtMP-Mgmt
ip address 10.73.85.129 255.255.255.128
no ip redirects
no ip unreachables
!
interface Vlan100
description ALU-NGN-Signaling
ip vrf forwarding V1464:STC-NGN-Signalling
ip address 10.200.23.62 255.255.255.192
no ip redirects
no ip unreachables
no ip proxy-arp
load-interval 30
!
interface Vlan109
description By VPNSC: Job Id# = 30690 (SAMIS-RYAD07_00_241-RYAD07_00_241 IP1)
ip vrf forwarding V1373:SAMIS
no ip address
no ip unreachables
no ip proxy-arp
!
现在我想找到
ip vrf forwarding Access-Mgmt
ip address 10.156.207.254 255.255.255.192
即我想找到“Access-Mgmt”,只要“ip 地址”字符串后跟“ip vrf 转发”即可。
所以按照上述条件:
- 我应该得到 Access-Mgmt、IN_MEDIA_SIGNALING、Atheeb-VoIP、V3620:EBU-COMIS 等等。
- 我不应该得到 V1373:SAMIS(因为后面没有 ip 地址)
我们可以在 php 中使用 preg match all 来获得它吗?
【问题讨论】:
-
ip vrf forwarding (\S+)\s*ip address (.*)尚不清楚您实际上要获取什么,但这对我有用。 -
实际上我想将具有 ip 地址的 vrf 名称显示为活动的,而那些没有 IP 地址的则显示为非活动的
标签: php regex preg-match preg-match-all