在tcl语言中,我得到一些输出:
xCommand Experimental Conference ParticipantList Search CallId: 231
OK
*r ParticipantListSearchResult Participant 1 Index: 0
*r ParticipantListSearchResult Participant 1 ParticipantId: "sip:9503806@10.89.70.92;ci=23543253"
*r ParticipantListSearchResult Participant 1 Uri: "sip:9503806@10.89.70.92;ci=23543253"
*r ParticipantListSearchResult Participant 1 DisplayName: "9503806"
*r ParticipantListSearchResult Participant 1 Status: "connected"
*r ParticipantListSearchResult Participant 1 AudioMute: Off
*r ParticipantListSearchResult Participant 2 Index: 1
*r ParticipantListSearchResult Participant 2 ParticipantId: "sip:9503808@10.89.70.92;ci=23543256"
*r ParticipantListSearchResult Participant 2 Uri: "sip:9503808@10.89.70.92;ci=23543256"
*r ParticipantListSearchResult Participant 2 DisplayName: "9503808"
*r ParticipantListSearchResult Participant 2 Status: "connected"
*r ParticipantListSearchResult Participant 2 AudioMute: Off
*r ParticipantListSearchResult Participant 3 Index: 2
*r ParticipantListSearchResult Participant 3 ParticipantId: "sip:9503807@10.89.70.92;ci=23543254"
*r ParticipantListSearchResult Participant 3 Uri: "sip:9503807@10.89.70.92;ci=23543254"
*r ParticipantListSearchResult Participant 3 DisplayName: "9503807"
*r ParticipantListSearchResult Participant 3 Status: "connected"
*r ParticipantListSearchResult Participant 3 AudioMute: Off
** end
我需要:
DisplayName: "9503806"
DisplayName: "9503808"
DisplayName: "9503807"
作为我的输出,如何为它编写正则表达式?
答案 0 :(得分:1)
您只需要1张外卡即可匹配不同的数字和正确的功能。让我们说你的文字在变量$output
中,然后执行:
set results [regexp -all -inline -- {DisplayName: "[0-9]+"} $output]
$results
是一个列表。因此,如果您想将它们打印在另一个之下,您可以这样做:
puts [join $results \n]
答案 1 :(得分:0)
DisplayName: "[0-9]*"