Jump to content

Recommended Posts

Posted

I'm trying to match a single number and nothing else, this is what I got so far.

obviously this does not work.

if StringRegExp("1",'\<\d\>',0) Then

MsgBox(0,"yes","matched")

EndIf

but, if i try '\d\>' it matches it but then it will match anything that ends with a digit.

Posted

This works:

Global $s_test = "1"

$result = StringRegExp($s_test, "[0-9]", 0)
If $result Then 
    MsgBox(0, "Found", "Number was in the string!")
Else
    MsgBox(0, "Not Found", "No number was found in the string!")
EndIf
oÝ÷ ØêÚºÚ"µÍÌÍÜÝ[HÝ[ÔYÑ^
    ÌÍÜ×ÝÝ    ][ÝÉÌLÙ ][ÝË
AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)
Posted

the string has to be only a number not a number found in the string. I dont want matches to abc1. Basically, only a number nothing else in sting.

Posted

The below will match only numbers but I didn't know if you wanted to match Only a single digit or multiple digits. This will match any digit numbers but will fail if there are spaces or commas

$String = "3"
if not StringRegExp($String, "\D", 0) Then
    if StringRegExp($String, "\d", 0) Then
        MsgBox(0, "Match", "The string was a number only")
    Else
        MsgBox(0, "no match", "The string did not contain numbers")
    EndIf
Else
    MsgBox(0, "no match", "The string contained more than numbers")
EndIf

Mike

Posted

That will work but why doesn't this? This will not work for some reason.

\< means match beginning

\> means match end

if StringRegExp("1",'\<\d\>',0) Then

MsgBox(0,"yes","matched")

EndIf

[\code]

I believe there are some bugs in the \< but \> works

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...