所以我为SecureCRT做了一个vbs脚本,但是它不起作用。脚本应该查看文本内部并检查所有接口,然后通过为每个接口发出一个命令来循环它们。我收到的错误在代码行中(Set matches = re.Execute(allthetext)),它的意思是(意外的量词)。
我希望能找到一个独处
$language = "VBScript"
$interface = "1.0"
crt.Screen.Synchronous = True
Sub Main ()
allthetext = "ge-10/1/2 but not ae22 and as well ge-1/0/0 in addtion xe-0/0/0:2, lets see"
Set re = New RegExp
re.Pattern = "\b{2}-\d{1,3}-\d{1,3}-\d{1,3}:\d|\b{2}-\d{1,3}-\d{1,3}-\d{1,3}"
Set matches = re.Execute(allthetext)
For Each match In matches
theInterface = match.SubMatches(0)
crt.Screen.Send "show interfaces " & theInterface & "| match ""down"" " & chr(13)
Next
End Sub发布于 2022-10-01 09:00:20
该模式不工作,因为这一部分\b{2},其中有一个量词边界,但不工作。
您可以这样编写模式,但请注意,在启动-之前应该有一个单词字符
\b-\d{1,3}-\d{1,3}-\d{1,3}:\d|\b-\d{1,3}-\d{1,3}-\d{1,3}由于破折号和数字部分的模式有一些重叠,所以可以使用可选的:部分和最后的数字组(?::\d)?重写它。
\b-\d{1,3}-\d{1,3}-\d{1,3}(?::\d)?看到匹配的regex演示。
https://stackoverflow.com/questions/73916355
复制相似问题