Thomymaster Posted July 9, 2015 Share Posted July 9, 2015 Hi Does anybody of you have a hint for me on how to check this:I have a string that should only contain digits (0-9) a optionally comma "," or a dot "."so99,19.2 Everything else shouldn't be allowed. Best,Thomas Link to comment Share on other sites More sharing options...
kylomas Posted July 9, 2015 Share Posted July 9, 2015 Thomymaster,One solution...local $sString = '9.0,1,3' if stringregexp($sString,'[^\d\.\,]') then ConsoleWrite('Invalid String' & @CRLF) Else ConsoleWrite('Valid String' & @CRLF) endif ; or shorthand version ConsoleWrite((stringregexp($sString,'[^\d\.\,]') ? 'Invalid' : 'Valid') & ' string' & @CRLF)kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
mikell Posted July 9, 2015 Share Posted July 9, 2015 #Include <Array.au3> local $sString = "so" &@crlf& "9" &@crlf& "9.1" &@crlf& "test" &@crlf& "9,2" ;Msgbox(0,"", $sString) $aString = StringRegExp($sString, '\V+', 3) _ArrayColInsert($aString, 1) For $i = 0 to UBound($aString)-1 $aString[$i][1] = StringRegExp($aString[$i][0], '[^\d.,]') ? "nope" : "OK" Next _ArrayDisplay($aString) Link to comment Share on other sites More sharing options...
jguinch Posted July 9, 2015 Share Posted July 9, 2015 Does anybody of you have a hint for me on how to check this:I have a string that should only contain digits (0-9) a optionally comma "," or a dot "."So, are "1." or ".1" or "1.2.3" good or not ?Local $aStrings[7] = [ "something", "05", "1.2", "1.", ".3", "10.2", "12.2,3"] For $i = 0 To UBound($aStrings) - 1 ConsoleWrite($aStrings[$i] & " : ") If StringRegExp($aStrings[$i], "^\d+([,.]\d+)?$") Then ConsoleWrite("good" & @CRLF) Else ConsoleWrite("not good" & @CRLF) EndIf Next Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Thomymaster Posted July 10, 2015 Author Share Posted July 10, 2015 Thats works fine, thanks a lot 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