Jump to content
Sign in to follow this  
Alexxander

Get numbers from a sentence ?

Recommended Posts

Alexxander

Hello i have this sentence

 

[24] hi all i'am an example

 

is there is a way to get all the numbers in this sentence ?

i want Autoit to give me 24 in a variable is this possible ?


Share this post


Link to post
Share on other sites
FireFox

Hi,

Have you looked at the String* functions in the helpfile? Especially StringMid/StringInStr or _StringBetween? (or StringRegExp but I doubt you will be able to do something with it).

Br, FireFox.

  • Like 1

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
Terenz

Local $aFinal
$aString = "[24] hi all i'am an example"
$aResult = StringRegExp($aString, "\d", 3)
For $x = 0 To UBound($aResult) -1
    $aFinal &= $aResult[$x]
Next
ConsoleWrite($aFinal)

  • Like 1

Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Share this post


Link to post
Share on other sites
FireFox

This is a trivial question, giving an example is not going to solve his lack of "reading the helpfile".

  • Like 1

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
Alexxander

Terenz

thank you bro appreciated

------------------------------------------------------------------------------------------------------------------------------------------------------------------

FireFox

thank you man you are a teacher and i am so lazy :P

Edited by Alexxander

Share this post


Link to post
Share on other sites
FireFox

Alexxander,

The RegExp solution given will extract all numbers, if you want only to extract the numbers between brackets, use this simple pattern: "[d]".

PS: A forum search will be faster than creating a topic and waiting for answers ;)

Br, FireFox.

  • Like 1

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
Malkey

 

Alexxander,

The RegExp solution given will extract all numbers, if you want only to extract the numbers between brackets, use this simple pattern: "[d]".

 

PS: A forum search will be faster than creating a topic and waiting for answers ;)

 

Br, FireFox.

FireFox

Bad guess.

"[d]" is  the same as "[0-9]" which is the same as "d".

If you want only to extract the numbers between brackets, use this simple pattern: "[(d+)]".

Edited by Malkey
  • Like 1

Share this post


Link to post
Share on other sites
FireFox

 

FireFox

Bad guess.

"[d]" is  the same as "[0-9]" which is the same as "d".

If you want only to extract the numbers between brackets, use this simple pattern: "[(d+)]".

Yes sure  :>

  • Like 1

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

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  

×