VicTT Posted August 22, 2005 Posted August 22, 2005 (edited) Hmm..I'm looking to parse an expression of this type in the most efficient manner possible using AutoIt(rather than using a for-loop as I would have done in PASCAL/C, I would want to use AutoIt built-in String manipulation functions )::<text1>!~<text2>@<text3>So if $s were this expression, I would need CLEAN and easy to read code to split $s into it's three main components..$text1,$text2,$text3..A function would be nice.. Edited August 22, 2005 by VicTT Quote Together we might liveDivided we must fall
trids Posted August 22, 2005 Posted August 22, 2005 (edited) Suggestion:Take it a step at a time. First StringSplit on "<" .. This gives you all your values "cleaned" on the left hand side, in an array.Next, StringSplit each array item on ">", and you'll have the values you seek all cleaned in element [1] of the resulting arrays.HTH Edit: spelling! Edited August 22, 2005 by trids
VicTT Posted August 22, 2005 Author Posted August 22, 2005 :Whatever!~Igotno@inspiration There are no < >'s they are put there just to show that <text1> must be replaced by something..ANYTHING non-null.. Quote Together we might liveDivided we must fall
VicTT Posted August 22, 2005 Author Posted August 22, 2005 I'll just settle with $text1=StringMid($s,2,StringLen($s)-StringInStr($s,"!~")) $text2=StringMid($s,StringInStr($s,"!~"),StringLen($s)-StringInStr($s,"@")) $text3=StringMid($s,StringInStr($s,"@"),StringLen($s)); Doesn't matter how many chars anymore Hope that works .. Quote Together we might liveDivided we must fall
VicTT Posted August 22, 2005 Author Posted August 22, 2005 Nope..didn't work..but this does..Very ugly for pure debuggish purposes $s=InputBox("String Input",":<text1>!~<text2>@<text3>") $text1=StringMid($s,2,StringInStr($s,"!~")-StringLen("!~")) $text2=StringMid($s,StringInStr($s,"!~")+StringLen("!~"),StringLen($s)-StringInStr($s,"@")) $text3=StringMid($s,StringInStr($s,"@")+StringLen("@"),StringLen($s)); Doesn't matter how many chars anymore Msgbox(0,"Split",$text1&" "&$text2&" "&$text3) Hopefully I'll make a general func to split stuff..and I've got the right ideas..bad thing is I gotta meet my gf in minus 20 minutes..Cyaz.. Quote Together we might liveDivided we must fall
GaryFrost Posted August 22, 2005 Posted August 22, 2005 $test = "Whatever!~Igotno@inspiration" $array = StringSplit($test,"!~",1) MsgBox(0,"test",$array[1] & @LF & $array[2]) SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
/dev/null Posted August 22, 2005 Posted August 22, 2005 So if $s were this expression, I would need CLEAN and easy to read code to split $s into it's three main components..$text1,$text2,$text3..A function would be nice..RegExp is your friend!$test = ":text1!~text2@text3" $vResult = StringRegExp($test, ":(.*)!~(.*)@(.*)", 1) if @extended then msgbox(0,"",$vResult[0] & ":" & $vResult[1] & ":" & $vResult[2]) else msgbox(0,"ERROR", "Pattern not found") endifCheersKurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *
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