繁体   English   中英

RegEx将多行文件与VB,net匹配

[英]RegEx match multiline file with 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执行此操作?

非常感谢

删除模式开头的^标记:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM