Jump to content
Sign in to follow this  
EX10TION

taking integer values only from clipboard

Recommended Posts

EX10TION

just need help to extract integers from this:

$speed = _ClipBoard_GetData()

so if the clipboard had "kijs123ki8 9 asd3" speed will = 123893

thanks

Share this post


Link to post
Share on other sites
oMBRa

#include <Array.au3>

ClipPut('lolol12ll12')
$speed = StringRegExp(ClipGet(), '[0-9]', 3)
If Not @error Then
    MsgBox(0, '', _ArrayToString($speed, ''))
Else
    MsgBox(0, '', 'No numbers found')
EndIf

Share this post


Link to post
Share on other sites
martin

just need help to extract integers from this:

so if the clipboard had "kijs123ki8 9 asd3" speed will = 123893

thanks

$s = "kijs123ki8 9 asd3" 
;speed will = 123893
$speed = StringRegExpReplace($s,"[^0-9]","")
ConsoleWrite( $speed & @CRLF)

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
IndyUK

just need help to extract integers from this:

so if the clipboard had "kijs123ki8 9 asd3" speed will = 123893

thanks

My suggestion would be to iterate through the string 1 character at a time and if you hit a number store that in a temp variable. Once the process complets you will have your number.

Share this post


Link to post
Share on other sites
oMBRa

$s = "kijs123ki8 9 asd3" 
;speed will = 123893
$speed = StringRegExpReplace($s,"[^0-9]","")
ConsoleWrite( $speed & @CRLF)
better way than mine, I forgot the ''^'' xD

Share this post


Link to post
Share on other sites
EX10TION

thanks for the fast reply dudes... and it worked out ^^

Share this post


Link to post
Share on other sites
EX10TION

uhm okay i forgot about the decimal point

my program copies something like this

text text text 61.2384 text

and i need that decimal point.. :)

Share this post


Link to post
Share on other sites
EX10TION

nvm... figured it out lol...

$speed = StringRegExpReplace($s,"[^0-9.]","")

u just add it after the 9 :)

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  

×