限定一个单词边界就行了,用 \W 或 \b 都行- Set fso = CreateObject("scripting.filesystemobject")
- text = fso.OpenTextFile("a.txt",1).ReadAll
-
- Set re = New RegExp
- re.Global = True
- re.IgnoreCase = True
- re.MultiLine = True
-
- key = "(?:1?\d?\d|2[0-4]\d|25[0-5])"
- re.Pattern = "\b" & key & "\." & key & "\." & key & "\." & key & "\b"
-
- set ex = re.Execute(text)
- For Each e In ex
- str = str & e & vbCrLf
- Next
- WScript.Echo str
复制代码
|