0

我有一个充满数字的网页,例如:

xxxx.xxx.xxx.xxx[space]xx

例如:

124.240.187.79 82

如何以编程方式搜索和获取它们?

4

1 回答 1

0

正则表达式03.vbs:

Dim objRegExp    : Set objRegExp = CreateObject("VBScript.RegExp")
objRegExp.Global = True
Dim input
input = "I have a webpage full of numbers like: xxxx.xxx.xxx.xxx[space]xx E.g.: 124.240.187.79 82 How do I search and get them programatically?"

Dim Pattern : Pattern = "[0-9]{3}\.[0-9]{3}\.[0-9]{3}\.[0-9]{2}\s[0-9]{2}"
WScript.Echo "Pattern : " & Pattern

objRegExp.Pattern = Pattern

Set objMatches = objRegExp.Execute(input)

For i=0 To objMatches.Count-1
  Set objMatch = objMatches.Item(i)
  WScript.Echo objMatch.Value
Next

命令行:

cscript //nologo regexp03.vbs 

输出:

Pattern : [0-9]{3}\.[0-9]{3}\.[0-9]{3}\.[0-9]{2}\s[0-9]{2}
124.240.187.79 82
于 2013-02-08T22:50:00.447 回答