我的网页上有很多数字:
xxxx.xxx.xxx.xxx[space]xx
E.g:
124.240.187.79 82
如何以编程方式搜索和获取它们?
答案 0 :(得分:0)
regexp03.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