Page 1 of 1

Extract IP address from text file.

Posted: 28 Jul 2009 23:08
by test123
Hi Script Experts,

I have on text file, it generated from wget.exe. ( It is my isp wan ip)

I need one script to extract only the ip address. ( just like 92.99.191.63) only.

Here some time ip will show 256.99.192.123

ip.txt
--------
<html><head><title>Current IP Check</title></head><body>Current IP Address: 92.99.191.63</body></html>

Thanks in advance.


Regards,

Baiju.

Posted: 29 Jul 2009 18:27
by ghostmachine4
you can use vbscript

Code: Select all

Set objFS = CreateObject("Scripting.FileSystemObject")
Set objRE = New RegExp
objRE.Pattern = "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"
objRE.Global     = True
objRE.IgnoreCase = False
objRE.MultiLine = True
strFile = "c:\test\file.txt"
strFileContents = objFS.OpenTextFile(strFile).ReadAll
Set colMatches = objRE.Execute(strFileContents)
For Each objMatch In colMatches
   WScript.Echo objMatch.Value
Next


Posted: 29 Jul 2009 22:39
by test123
Hi ghostmachine4,

Many thanks, It works !

Regards,

BAIJU