Jump to content
Sign in to follow this  
VicTT

Expression parsing

Recommended Posts

VicTT

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 by VicTT

[quote]Together we might liveDivided we must fall[/quote]

Share this post


Link to post
Share on other sites
trids

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

:whistle:

Edit: spelling!

Edited by trids

Share this post


Link to post
Share on other sites
VicTT

: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[/quote]

Share this post


Link to post
Share on other sites
VicTT

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 :whistle:..


[quote]Together we might liveDivided we must fall[/quote]

Share this post


Link to post
Share on other sites
VicTT

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[/quote]

Share this post


Link to post
Share on other sites
/dev/null

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")
endif

Cheers

Kurt


__________________________________________________________(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 *

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.