7121 Posted January 18, 2009 Share Posted January 18, 2009 Basically here's what i did, i think i posted in the past about this but it didn't make sense.Here's how it goes.Here is what was copied, 2 + 4 =$string = Clipget()$data = StringRegExp( $string, "=", "" )this is where i'm lost.it's still a string rather than expression, what should i do to turn it into one?so that when i do Msgboxit won't come out as 2 + 4, but 6 instead.In addition, what happens if let's say this comes up, 2², or 3². How how i change that into a 2^2 or 3^2 for a string (which i'll switch later on expression anyways) Link to comment Share on other sites More sharing options...
Dreamfire Posted January 18, 2009 Share Posted January 18, 2009 (edited) Here you go, $sTEXT = '2 + 4 =' $aTMP = StringRegExp($sTEXT,"([0-9]{1,9}) [+] ([0-9]{1,9})",1) $sRESULT = $aTMP[0] + $aTMP[1] MsgBox(0,'RESULT',$sRESULT) Edited January 18, 2009 by Dreamfire Link to comment Share on other sites More sharing options...
rasim Posted January 18, 2009 Share Posted January 18, 2009 Another way: $sTEXT = '2 + 4' $aTMP = StringRegExp($sTEXT, "\d{1,}\s?\+\s?\d{1,}", 1) If @error Then Exit $sRESULT = Execute($aTMP[0]) MsgBox(0, 'RESULT', $sRESULT) Link to comment Share on other sites More sharing options...
7121 Posted January 18, 2009 Author Share Posted January 18, 2009 so wait, how'd u turn the string from the clipobard into an expression o_0??? Link to comment Share on other sites More sharing options...
Malkey Posted January 18, 2009 Share Posted January 18, 2009 And another way.$aTMP = '(12/4 + 3²)*2 =' ClipPut($aTMP) $sTEXT = ClipGet() ; Using ² equal to ASCII 0xB2 $aTMP = StringRegExpReplace(StringRegExpReplace(StringRegExpReplace($sTEXT, _ "(\xB2)", "^2"), "(\xB3)", "^3"), "=", "") MsgBox(0, 'RESULT', $sTEXT & " " & Execute($aTMP))Lookup the Execute() function in help. (Execute an expression.) 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