Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regexp与TCL上的字符串匹配 接口IP地址正常吗?方法状态协议 千兆以太网0/0/0未分配是NVRAM向上 Gi0/0/0.201 10.10.10.30是NVRAM向上 千兆以太网0/1未分配是NVRAM管理关闭 GigabitEthernet0/1.201未分配是手动管理关闭 千兆以太网0/2/0 1.2.3.4是NVRAM启动 千兆以太网0/2/0.203 10.10.10.1是NVRAM启动_Regex_Tcl_String Matching - Fatal编程技术网

Regexp与TCL上的字符串匹配 接口IP地址正常吗?方法状态协议 千兆以太网0/0/0未分配是NVRAM向上 Gi0/0/0.201 10.10.10.30是NVRAM向上 千兆以太网0/1未分配是NVRAM管理关闭 GigabitEthernet0/1.201未分配是手动管理关闭 千兆以太网0/2/0 1.2.3.4是NVRAM启动 千兆以太网0/2/0.203 10.10.10.1是NVRAM启动

Regexp与TCL上的字符串匹配 接口IP地址正常吗?方法状态协议 千兆以太网0/0/0未分配是NVRAM向上 Gi0/0/0.201 10.10.10.30是NVRAM向上 千兆以太网0/1未分配是NVRAM管理关闭 GigabitEthernet0/1.201未分配是手动管理关闭 千兆以太网0/2/0 1.2.3.4是NVRAM启动 千兆以太网0/2/0.203 10.10.10.1是NVRAM启动,regex,tcl,string-matching,Regex,Tcl,String Matching,这是路由器上命令的一些输出。我希望能够匹配以Gi或gigabiteethernet开头并以.20(1-20)结尾的字符串,比如.201或.202或.203直到.220 因此它将匹配gigabiteEthernet0/1.201或Gi0/0/0.201 一旦存在匹配项,我希望能够将完整的字符串放入变量中,并在其他地方使用它。如果有多个匹配项,我希望它们包含在多个变量中 请编码员帮我。非常感谢你的帮助。提前谢谢 Interface IP-Address O

这是路由器上命令的一些输出。我希望能够匹配以
Gi
gigabiteethernet
开头并以
.20(1-20)
结尾的字符串,比如
.201
.202
.203
直到
.220

因此它将匹配
gigabiteEthernet0/1.201
Gi0/0/0.201

一旦存在匹配项,我希望能够将完整的字符串放入变量中,并在其他地方使用它。如果有多个匹配项,我希望它们包含在多个变量中

请编码员帮我。非常感谢你的帮助。提前谢谢

Interface IP-Address OK? Method Status Protocol GigabitEthernet0/0/0 unassigned YES NVRAM up up Gi0/0/0.201 10.10.10.30 YES NVRAM up up GigabitEthernet0/1 unassigned YES NVRAM admin down down GigabitEthernet0/1.201 unassigned YES manual admin down down GigabitEthernet0/2/0 1.2.3.4 YES NVRAM up up GigabitEthernet0/2/0.203 10.10.10.1 YES NVRAM up up
请参见和

Gi(?:gabitEthernet)。*?\.2(?:0[1-9]| 1\d | 20)。*
?尝试我添加了单词边界
\m
\m
,这样您就不会匹配“xxxGi0.2012345”之类的内容。谢谢你,格伦。你这么说真是太棒了。与此同时,我一直在尝试并提出了(Gi.+)(\/[0-2])([./]?)([2][0-2][1-9])。它给了我匹配,但我喜欢数字只在1个子串。再次感谢
set text {Interface                  IP-Address      OK? Method Status           Protocol

GigabitEthernet0/0/0        unassigned      YES NVRAM  up                    up
Gi0/0/0.201                 10.10.10.30     YES NVRAM  up                    up
GigabitEthernet0/1          unassigned      YES NVRAM  admin down           down
GigabitEthernet0/1.201       unassigned     YES manual admin down           down
GigabitEthernet0/2/0        1.2.3.4         YES NVRAM  up                    up
GigabitEthernet0/2/0.203    10.10.10.1      YES NVRAM  up                    up }

set interfaces [regexp -all -inline {\mGi\S+\.2(?:0[1-9]|1[0-9]|20)\M} $text]
puts $interfaces
Gi0/0/0.201 GigabitEthernet0/1.201 GigabitEthernet0/2/0.203