sammy1983 Posted August 19, 2014 Share Posted August 19, 2014 (edited) 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. Edited August 19, 2014 by sammy1983 Link to comment Share on other sites More sharing options...
mikell Posted August 19, 2014 Share Posted August 19, 2014 ? #Include <Array.au3> $str = "(if contractor)Static IP RangesIn House 148.186.25.1Outside Office 1 148.186.25.2 Outside Office 2Contractor 1Contractor 2" $res = StringRegExp($str, '([\d.]{8,})', 3) _ArrayDisplay($res) Link to comment Share on other sites More sharing options...
jguinch Posted August 19, 2014 Share Posted August 19, 2014 #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 Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
sammy1983 Posted August 19, 2014 Author Share Posted August 19, 2014 ? #Include <Array.au3> $str = "(if contractor)Static IP RangesIn House 148.186.25.1Outside Office 1 148.186.25.2 Outside Office 2Contractor 1Contractor 2" $res = StringRegExp($str, '([\d.]{8,})', 3) _ArrayDisplay($res) Thanks a ton, Universalist.. This worked like charm.. U made my day.. Thanks again..!!!! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now