Jump to content

Unable to extract IP address


Recommended Posts

Hi,

Need help badly here...

I have a Word doc which has information as shown in the screenshot.

 

When I read the lines from the doc, I am receiving the entire content of the table in one line like below.

(if contractor)Static IP RangesIn House 148.186.25.1Outside Office 1Outside Office 2Contractor 1Contractor 2

No I am unable to extract just the IP address. Any help would be greatly appreciated. Thanks.

post-80752-0-74353400-1408421063_thumb.j

Edited by sammy1983
Link to comment
Share on other sites

#Include <Array.au3>

Local $data = 'Static IP RangesIn House 148.186.25.1Outside Office 1Outside Office 2Contractor 1Contractor 2'
$aIP = _IPv4_Extract($data)

_ArrayDisplay($aIP)


Func _IPv4_Extract($sIP)
    $pattern = "(?x) (?<!\d|\d\.) ( (?:(?:  (?:(?:25[0-5]  |  2[0-4]\d  |  1\d{2}  | [1-9]\d  |  \d  )\.){3}   (?:25[0-5]  |  2[0-4]\d  |  1\d{2}  | [1-9]\d  |  \d  )  ) " & _
    " | " & _
    "(?:  (?:(?:25[0-5]  |  2[0-4]\d  |  [0-1]\d{2}  |  (00)\d  )\.){3}   (?:25[0-5]  |  2[0-4]\d  |  [0-1]\d{2}  |  (?:00)\d) )) )  (?!\d|\.\d)"

    Return StringRegExp($sIP, $pattern, 3)
EndFunc

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...