Jump to content

Recommended Posts

Posted (edited)

$number = 2.3
$number1 = 1.5
$ok = ""&$number&", "&$number1&"j"

How do I extract $number and $number1 from the string and set them separately to float point numbers again?

I tried the help file but couldnt find anything that could help me

Edited by Ultima2
Posted

$number = 2.3
$number1 = 1.5
$ok = ""&$number&", "&$number1&"j"

How do I extract $number and $number1 from the string and set it to a float point number again?

I tried the help file but couldnt find anything that could help me

Hi,

For extract it you can use string functions :

StringSplit

StringLeft

StringRight

StringTrimLeft

StringTrimRight

StringReplace

........

Posted

Could you post an example please, that doesn't really help me because im still a newbie D:

$String="Number 1.5 and Number 2"
$Number1=StringLeft(StringTrimLeft($String,7),3)
$Number2=StringRight($String,1)
Msgbox(64,"",$Number1&" and "&$Number2)

You can check this functions on autoit helpfile with F1 key in SciTE :)

Posted (edited)

Ok thank you very much, but what if you dont know the exact digit of the number, like log(3).

Like

$x = log(3)
$z = log(2)
$ok = ""&$x&", "&$z&""

How would you extract the entire value of $x and $z from the string? Thanks :)

Edited by Ultima2
Posted

Ok thank you very much, but what if you dont know the exact digit of the number, like log(3).

Like

$x = log(3)
$z = log(2)
$ok = ""&$x&", "&$z&""

How would you extract the entire value of $x and $z from the string? Thanks :)

Do you want to search all numbers in a log ? (1-9)
Posted

Try this :)

#include <Array.au3>

$x = log(3)
$z = log(2)
$ok = ""&$x&", "&$z&""

;~ $number = 2.3
;~ $number1 = 1.5
;~ $ok = ""&$number&", "&$number1&"j"

ConsoleWrite($ok)


$new = StringRegExpReplace($ok,"[^0-9.\s]","")
$array = StringSplit($new, " ")
_ArrayDisplay($array)
Posted

No I just want to know how to extract a number from a string. How do I extract a number from a string if I dont know the exact length of the number. like sqrt(5).

Posted

No I just want to know how to extract a number from a string. How do I extract a number from a string if I dont know the exact length of the number. like sqrt(5).

if you don't length of the number you have to search it... look at StringRegExp , Stringinstr
Posted

I cant understand the help file. They're like written for people with 180+ IQ. Like for the code

$x = log(3)
$z = log(2)
$ok = ""&$x&", "&$z&""

I have a string "$x, $z". How do I extract $x and $z from the string. I cant use the method you showed me earlier because it only works if I know the exact length of log(3) and log(2).

Posted (edited)

$number = 2.3
$number1 = 1.5
$ok = ""&$number&", "&$number1&"j"

ConsoleWrite($ok & @CR)

$new = StringRegExpReplace($ok,"[^0-9.\s]","")
$array = StringSplit($new, " ")
ConsoleWrite($array[1] & " " & $array[2] & @CR)

$x = log(3)
$z = log(2)
$ok = ""&$x&", "&$z&""

ConsoleWrite($ok & @CR)

$new = StringRegExpReplace($ok,"[^0-9.\s]","")
$array = StringSplit($new, " ")
ConsoleWrite("x=" & $array[1] & " z=" & $array[2] & @CR)

If this isn't what you asked for please explain how you mean.

Edited by Pain

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
  • Recently Browsing   0 members

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