copyright Posted September 22, 2004 Share Posted September 22, 2004 I went through the help file and did tests.. . and i just can't get what i need. perhaps one of you autoit geniuses can help: ok on the chat i have this.. style 1: copyright (Uptime: 01:43:13, 67 msgs sent) from 76.216.66.114 24 files style 2: copyright (Uptime: 01:53:57, 29 msgs sent) from 76.216.66.114 style 3: copyright: 76.216.66.114 Last seen 09/22/2004 07:57:13 the three different whois's.. how is it possible to store "only" the ip address of the user in each of these cases. if it helps i noticed theres always two spaces in between the ip address and the number of files the user has in the first style.. but then again, i could always be wrong.. i just need three different examples for each case! please, thanks a bunch guys! what would be the most accurate way of getting just the ip.. Link to comment Share on other sites More sharing options...
emmanuel Posted September 22, 2004 Share Posted September 22, 2004 I went through the help file and did tests.. . and i just can't get what i need. perhaps one of you autoit geniuses can help: ok on the chat i have this.. style 1: copyright (Uptime: 01:43:13, 67 msgs sent) from 76.216.66.114 24 files style 2: copyright (Uptime: 01:53:57, 29 msgs sent) from 76.216.66.114 style 3: copyright: 76.216.66.114 Last seen 09/22/2004 07:57:13 the three different whois's.. how is it possible to store "only" the ip address of the user in each of these cases. if it helps i noticed theres always two spaces in between the ip address and the number of files the user has in the first style.. but then again, i could always be wrong.. i just need three different examples for each case! please, thanks a bunch guys! what would be the most accurate way of getting just the ip.. <{POST_SNAPBACK}>hmmm... maybe a select case, where you check the format with the three know variations and then do a string strip based on that? Select case StringInStr($string, "sent) from ");in the case of this format: "copyright (Uptime: 01:43:13, 67 msgs sent) from 76.216.66.114 24 files" ;do some string trims to get the ip EndSelect with cases for each possible format? "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
Valik Posted September 22, 2004 Share Posted September 22, 2004 StringSplit() the line by space, then in the new array, test each element for having 3 periods using StringInStr(). The one with 3 periods is the element you want. Link to comment Share on other sites More sharing options...
CyberSlug Posted September 22, 2004 Share Posted September 22, 2004 (edited) Following should work if the only time a dot appears in the string is inside an IP Address and if there is always a space before and after the address: MsgBox(4096,"one", parseIP("copyright (Uptime: 01:43:13, 67 msgs sent) from 76.216.66.114 24 files")) MsgBox(4096,"two", parseIP("copyright (Uptime: 01:53:57, 29 msgs sent) from 76.216.66.114 ")) MsgBox(4096,"three", parseIP("copyright: 76.216.66.114 Last seen 09/22/2004 07:57:13")) Exit Func parseIP($str) $str = $str & " "; quick hack to make the second case works ; Get occurrance of first dot in string Local $dotPos = StringInStr($str, ".") ; Get first space closest to that dot Local $spacePos = $dotPos While $spacePos > 1 $spacePos = $spacePos - 1 If StringMid($str, $spacePos, 1) = " " Then ExitLoop Wend ; Read from that position to the next space $endPos = StringInStr( StringTrimLeft($str, $spacePos) , " ") Return StringMid($str, $spacePos, $endPos) EndFunc Edit: Er, use Valik's method Func valik($str) Local $a = StringSplit($str, " ") For $i = 1 to $a[0] If _StringCount($a[$i], ".") = 3 Then Return $a[$i] Next Return "" EndFunc ; helper function... why isn't this built in to AutoIt??? func _stringcount($Si,$Sf) if stringlen($Sf)<1 then exit $ts = StringSplit(stringreplace($Si,$Sf,chr(01)),chr(01)) return($ts[0]-1) endfunc Edited September 22, 2004 by CyberSlug Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
Valik Posted September 22, 2004 Share Posted September 22, 2004 Or (Untested)... Func ParseIP($string) Dim $a = StringSplit($string, " ") Local $i For $i = 1 To $a[0] If StringInStr($a[$i], ".", 0, 3) Then Return $a[$i] Next Return "" EndFunc Link to comment Share on other sites More sharing options...
emmanuel Posted September 22, 2004 Share Posted September 22, 2004 Or (Untested)... Func ParseIP($string) Dim $a = StringSplit($string, " ") Local $i For $i = 1 To $a[0] If StringInStr($a[$i], ".", 0, 3) Then Return $a[$i] Next Return "" EndFunc <{POST_SNAPBACK}>I tested it, it works. RIght on. I'll save that one for later.... "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
copyright Posted September 23, 2004 Author Share Posted September 23, 2004 I tested it, it works. RIght on. I'll save that one for later.... <{POST_SNAPBACK}>soooo..... what variable do i use to controlsend it to a window ? Link to comment Share on other sites More sharing options...
Valik Posted September 23, 2004 Share Posted September 23, 2004 Whatever variable you use to capture the return value of the function. 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