Sign in to follow this  
Followers 0
smellyfingers

Trouble with regexp, please help!

3 posts in this topic

Hi all, (im new to autoit scripting so bare with me :) been trying to make a script that lets you choose window and then choose the length of a number to find, problem is this, the script works in part of choosing window but if a number is longer it takes part of that number instead of searching for the exact length, the script works perfectly if the numbers on the window goes from little to bigger but not the other way around, im thinking maybe i can read the whole window, set the clipboard with the read info and sort the numbers in some way or is there any other approach for this, here is the script.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Compile_Both=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
$data2 =InputBox( "Exact name of the window to search" , "" )
$num2 = $data2
$data =InputBox( "Length to search for" , "" )
$num = $data
$Clip = WinGetText($num2)
$RegExp = StringRegExp ($Clip, "(\d{" & $num & "})", 1)
If IsArray ($RegExp) Then
clipput($RegExp[0])
EndIf

Thanx in advance!

Share this post


Link to post
Share on other sites



To select only numbers that are exactly the length specified change the regular expression line to this.

$RegExp = StringRegExp ($Clip, "\D(\d{" & $num & "})\D", 1)

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Share this post


Link to post
Share on other sites

Thanx Humanoid!, How much do i owe you :) this is great

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  
Followers 0