E1M1 Posted February 4, 2011 Share Posted February 4, 2011 IsNumber fails if number is formatted as string ($nr = "1234") So I need to do it other way. I cant figure out how to do it with stringregexp. Both returns me 0. StringRegExp("432","{0,9}") StringRegExp("432","[:digit:]") edited Link to comment Share on other sites More sharing options...
bogQ Posted February 4, 2011 Share Posted February 4, 2011 (edited) StringIsDigit for stringregexp i dono Edited February 4, 2011 by bogQ fraizor 1 TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
jvanegmond Posted February 4, 2011 Share Posted February 4, 2011 Your regular expressions are broken because they check if the string is ONE character between 0-9. Simply repeat with * and it will work. Although I should note that the syntax is not {0,9} but [0-9]... MsgBox(0, "", StringRegExp("432","[0-9]*")) github.com/jvanegmond Link to comment Share on other sites More sharing options...
E1M1 Posted February 4, 2011 Author Share Posted February 4, 2011 Thanks. edited Link to comment Share on other sites More sharing options...
ur Posted May 21, 2015 Share Posted May 21, 2015 It is not accurate.Even the below expression is giving 1.MsgBox(0, "", StringRegExp("g432.9h","[0-9]*"))andMsgBox(0, "", StringRegExp("hh","[0-9]*")) Link to comment Share on other sites More sharing options...
ur Posted May 21, 2015 Share Posted May 21, 2015 It is not accurate.Even the below expression is giving 1.MsgBox(0, "", StringRegExp("g432.9h","[0-9]*"))andMsgBox(0, "", StringRegExp("hh","[0-9]*")) Link to comment Share on other sites More sharing options...
ur Posted May 21, 2015 Share Posted May 21, 2015 StringIsDigit is giving only for integers but not for decimal values.MsgBox(0, "", StringIsDigit("123.89"))Returning 0.MsgBox(0, "", StringIsDigit("123"))Returning 1 Link to comment Share on other sites More sharing options...
jguinch Posted May 21, 2015 Share Posted May 21, 2015 StringIsFloat will return True, so you can use both StringIsFloat and StringIsDigit :$string = "1234.45" MsgBox(0, "", StringIsDigit($string) OR StringIsFloat($string) )For a regex :$string = "1234.45" MsgBox(0, "", StringRegExp($string, "^\d+(?:\.\d+)?$" ) ) Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
jchd Posted May 21, 2015 Share Posted May 21, 2015 Ahem, this still needs work: a number may be signed (+ or -), have no leading digit before the decimal point (e.g. .5) and then this regexp doesn't cope with reals in exp form, e.g. +123.45E-6 This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
jguinch Posted May 21, 2015 Share Posted May 21, 2015 Yes, you're right, but maybe it's enough for what the OP asks.This one should work :$string = "+.23E-22" MsgBox(0, "", StringRegExp($string, "(?i)^[+-]?(?:\d+\.?(?:\d+(?:e[+-]?\d+)?)?|\.?(?:\d+(?:e[+-]?\d+)?))$" ) )Or this way should work :$string = "+.23E-22" MsgBox(0, "", Execute($string) <> "" ) ; !!! returns True for an expression like "1 + 2" Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now