Jump to content

count from string


 Share

Recommended Posts

Welcome, i need help with calc script from string with func number

in example we got string

$string = '5+67='

and i need return 72 so Number(5+67)

i already try stringsplit with regexp but i do it without success.

If it easy for someone and can help me <>

thanks

Link to comment
Share on other sites

  • Developers

u didnt understand me ;/ i need made it from string

$string = '5+7='

not just 5+7

but thx

so ???

$string = '5+67='
$string = StringReplace($string, "=", '') ; strip the =
ConsoleWrite($string & "=" & Execute($string) & @CRLF)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

u didnt understand me ;/ i need made it from string

$string = '5+7='

not just 5+7

but thx

I did understand you but I wanted to show the Execute command!

You should be able to use any string function to remove the = from the string to execute the calculation!

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

#include <Array.au3>
$1 = '8+99 ='
$2 = '4+ 67='
$3 = '12 + 8 ?'
$4 = '66 +1 ?'
$5 = '54+ 8?'

cb($1)
cb($2)
cb($3)
cb($4)
cb($5)

Func cb($data)
    Local $Arr = StringSplit(StringReplace($data," ",""),"")
    Local $fi,$se,$del,$count=1
    If StringIsDigit($arr[1]) Then
        Do
            $del=$del&$Arr[$count]
            $count += 1
        Until Not StringIsDigit($arr[$count])
        $fi=$del
    Else
        Exit
    EndIf
    $del = ""
    Do
        $del=$del&$Arr[$count]
        $count += 1
    Until Not StringIsDigit($arr[$count])
    $se=$del
    ConsoleWrite(Execute($fi&$del)&@CRLF)
EndFunc

dumb way

Probably there is faster solution with StringRegExp

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

Is this one what you are looking for?

#include <Array.au3>
Dim $aStrings[5] = ['8+99 =', '4+ 67=', '12 + 8 ?', '66 +1 ?', '54+ 8?']
For $i = 0 To UBound($aStrings) - 1
    $aChk = StringRegExp(StringStripWS($aStrings[$i], 8), "[\d+]+[\+|\-|\*|\/][\d]+", 3)
    ConsoleWrite(Execute(_ArrayToString($aChk, "")) & @CRLF)
Next

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...