Prodigus Posted June 4, 2006 Posted June 4, 2006 I just want to grab the IP address out of this string 6/4/2006 12:10:46 PM | 23T7111.my.com (10.100.51.194) is alive. I would thing there would be a function where I could just grab whatever is between "(" and ")" Is there? The count would be different from left or right depending on the date and the IP address so I didn't think I could do it with a StringTrimLeft or right...
exodius Posted June 4, 2006 Posted June 4, 2006 (edited) I just want to grab the IP address out of this string 6/4/2006 12:10:46 PM | 23T7111.my.com (10.100.51.194) is alive. I would thing there would be a function where I could just grab whatever is between "(" and ")" Is there? The count would be different from left or right depending on the date and the IP address so I didn't think I could do it with a StringTrimLeft or right... Check out StringSplit in the helpfile for more info on how this works... $string = "6/4/2006 12:10:46 PM | 23T7111.my.com (10.100.51.194)" $Split = StringSplit ( $string, "(" ) $Split2 = StringSplit ( $Split[2], ")" ) MsgBox ( 0, "", $Split2[1] ) Edited June 4, 2006 by exodius
Nomad Posted June 4, 2006 Posted June 4, 2006 $String = StringSplit ( "6/4/2006 12:10:46 PM | 23T7111.my.com (10.100.51.194) is alive.", "(" & ")") MsgBox(0, "Return", $String[2]) Enjoy, Nomad
exodius Posted June 4, 2006 Posted June 4, 2006 (edited) $String = StringSplit ( "6/4/2006 12:10:46 PM | 23T7111.my.com (10.100.51.194) is alive.", "(" & ")") MsgBox(0, "Return", $String[2]) Enjoy, Nomad Fancy, I didn't know you could concatenate them like that. I understand how splitting the string at "(" gives you [2], but wouldn't you need the [1] of ")"? Edited June 4, 2006 by exodius
Nomad Posted June 4, 2006 Posted June 4, 2006 Fancy, I didn't know you could concatenate them like that. Yup. We were posting at the same time so I didn't see yours until I posted mine, hehe.
RazerM Posted June 4, 2006 Posted June 4, 2006 (edited) I would prefer to use stringbetween. They produce the same results and stringbetween is easier to use. $string = "6/4/2006 12:10:46 PM | 23T7111.my.com (10.100.51.194) is alive." $ip = StringSplit ( $string, "()") MsgBox(0, "StringSplit", "The ip is: " & $ip[2]) MsgBox(0, "StringBetween", "The ip is: " & _StringBetween($string, "(", ")")) Func _StringBetween($s, $from, $to) $x = StringInStr($s, $from) + StringLen($from) $y = StringInStr(StringTrimLeft($s, $x), $to) Return StringMid($s, $x, $y) EndFunc Edited June 4, 2006 by RazerM My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
exodius Posted June 4, 2006 Posted June 4, 2006 Fancy, I didn't know you could concatenate them like that. I understand how splitting the string at "(" gives you [2], but wouldn't you need the [1] of ")"? Just came to the realization that concatenating them like that splits the string up based upon those two characters instead of just one.
Nomad Posted June 4, 2006 Posted June 4, 2006 Just came to the realization that concatenating them like that splits the string up based upon those two characters instead of just one. I had to do a lot of string extracting not too long ago, so I got a lot of experience with using that command. Saved me a lot of lines in my script.
Prodigus Posted June 4, 2006 Author Posted June 4, 2006 Thanks!!!!! Solves a big problem I was having......
Valuater Posted June 4, 2006 Posted June 4, 2006 I had to do a lot of string extracting not too long ago, so I got a lot of experience with using that command. Saved me a lot of lines in my script. that is a nice, new one to me too!!8)
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