RegEx匹配多行文件与VB,net

时间:2015-11-05 16:14:46

标签: regex vb.net

我有这个文件之王:

<133>[S=88021847] [SID:1073707375] (   lgr_psbrdex)(72273723  )   pstn recv <-- CALL_DISCONNECTED Trunk:0 Conn:253 RetCause:104 NetCause:16 

<133>[S=88021848] [SID:1073707375] (      lgr_flow)(72273724  )   #31:LOCAL_CALL_DISCONNECTED_EV(Trunk:0 Conn:253 Bchannel:2 TpEv=67) 
(      lgr_flow)(72273725  )   |       #31:LOCAL_CALL_DISCONNECTED_EV 
(      lgr_flow)(72273726  )   |       #31:Close voice Channel 
(   lgr_psbrdif)(72273727  )   #31:StopRTP_RTCP on channel 31 

<133>[S=88021849] [SID:1073707375] (      lgr_flow)(72273728  )   |       #31:RELEASE_EV (send) GWAPP_NORMAL_CALL_CLEAR : (13389198304112015111113@192.168.150.20) 
(      lgr_flow)(72273729  )   |       |       #213:RELEASE_EV:(13389198304112015111113@192.168.150.20) 
(      lgr_flow)(72273730  )   |       |       #213:Call changing states from:ConnectedState to:DisconnectingState 

<133>[S=88021850] [SID:1073707375] (      lgr_flow)(72273732  )   |       |       #213:RELEASE_ACK_EV:(13389198304112015111113@192.168.150.20) 
(      lgr_flow)(72273733  )   EndPoint::MediaResourceList::FreeMediaIpPorts Perform dellocation of Media ports for RealmIndex(0) port(7440) current allocations are:(0) Owner:(0) 
(      lgr_flow)(72273734  )   |       |       |       (#45)SIPStackSession <- (#0)ENDPOINT: RELEASE_EV (13389198304112015111113@192.168.150.20) 
(     sip_stack)(72273735  )   New SIPMessage created - #3 
(      lgr_flow)(72273736  )   |       |(SIPTU#276)DISCONNECT_REQ State:Connected(13389198304112015111113@192.168.150.20) 
(      lgr_flow)(72273737  )   ---- Outgoing SIP Message to 192.168.150.1:5060 from SIPInterface #0 TcpTransportObject[#347] ---- 

我使用这种模式:

^<([^>]*)>(?:\[S=([^\]]*)\]\s+)?(?:\[SID:([^\]]*)\]\s+)?(.*)

使用VB.net,我的模式只产生一个匹配

Dim fullMatch As RegularExpressions.MatchCollection = RegularExpressions.Regex.Matches(readText, "^<([^>]*)>(?:\[S=([^\]]*)\]\s+)?(?:\[SID:([^\]]*)\]\s+)?(.*)", RegularExpressions.RegexOptions.IgnoreCase Or RegularExpressions.RegexOptions.Singleline)

我期待的是4场比赛,4场比赛,最后一组仍包含多线项目。

如何使用VB.net执行此操作?

非常感谢

1 个答案:

答案 0 :(得分:0)

在模式的最开头摆脱^令牌:

<([^>]*)>(?:\[S=([^\]]*)\]\s+)?(?:\[SID:([^\]]*)\]\s+)?(.*)