sammy1983 Posted August 19, 2014 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
mikell Posted August 19, 2014 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)
jguinch Posted August 19, 2014 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
sammy1983 Posted August 19, 2014 Author 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..!!!!
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