Jump to content
Sign in to follow this  
xdp22

string testing

Recommended Posts

xdp22

Hi, I need to do one thing, namely, checking whether the string contains and the number and digits, or if you suppose that we have a string - lol, the program will return 0, because the string contains only letters, let's say we have another string, for example - 123 as a program will return 0, but if we have a string, for example - lol123 a program will return 1 because it contains letters and numbers

Can somebody help me? Thank you :)

Edited by xdp22

Share this post


Link to post
Share on other sites
xdp22

yyy? bot mean Autoit code.. i using google translator.. sorry

Edited by xdp22

Share this post


Link to post
Share on other sites
xdp22

Nope.. read this topic and read earlier topic, earlier topic is for function StringIsDigit whan return 1 if string is only numbers, and return 0 if string is not only numbers, it's not that same, cuz StringIsDigit can't know string have letter's and numbers or only letters

Share this post


Link to post
Share on other sites
xdp22

I don't know how to do that really, i trying with StringRegExp but it's too hard for me ;/

Share this post


Link to post
Share on other sites
jaberwacky

Looks like it's time to roll up your sleeves and get to work making your own UDF.

Just break it down into steps:

1) If $string only contains letters then return 0

2) If $string only contains numbers then return 0

3) If $string contains both letters AND numbers then return 1

Share this post


Link to post
Share on other sites
xdp22

Man nope StringIsAlNum and StringIsASCII() can't help me, ASCII is ALL on keyboard, so including abcd - xyz, and 0-9.

StringIsAllNum just checking how much characters have string, not string is only 0-9 >.<

Share this post


Link to post
Share on other sites
jaberwacky

Well, good luck on your future programming endeavors. I and I am sure that others will be here to help you if you run into trouble, maybe. Only if you demonstate that you've exerted some effort into solving any problems that you may encounter.

I bid you peace.

Share this post


Link to post
Share on other sites
xdp22

Looks like it's time to roll up your sleeves and get to work making your own UDF.

Just break it down into steps:

1) If $string only contains letters then return 0

2) If $string only contains numbers then return 0

3) If $string contains both letters AND numbers then return 1

Ok i got that thank you

1) StringIsAlpha

2) StringIsDigit

3) Case

Here is mine version if someone want

$string = "lol123"
$liczby = StringIsDigit($string)
If $liczby = 0 Then
$litery = StringIsAlpha($string)

  If $litery = 0 Then
  $result = 1
  Else
  $result = 0
  EndIf
Else
$result = 0
EndIf

MsgBox( 0, "", $result)

@Down thanks

Edited by xdp22

Share this post


Link to post
Share on other sites
Bowmore

This may give you some more ideas for achieving what you want

;#include <file.au3> <=== not required
MsgBox(0,"result",teststring("lol123"))
Func teststring($s)
    Local $x = 0

    If StringIsAlNum($s) Then $x += 1
    If StringIsDigit($s) Then $x += 2
    If StringIsInt($s) Then $x += 4
    If StringIsFloat($s) Then $x += 8
    Return $x
EndFunc
Edited by Bowmore

"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
guinness

jaberwocky6669 means that if you try to show you are coding you are more likely to get help from users here, plus I suggest looking in the Help File for Functions because these are your friends :)

$String = "78fff9"
MsgBox(0, "_CheckString()", _CheckString($String) & " >> " & @error) ; It Returns an @error = 1 and -1 if nothing else matches.

Func _CheckString($sString)
    If StringIsAlpha($sString) Or StringIsDigit($sString) Then Return 0 
    If StringIsAlNum($sString) Then Return 1
    Return SetError(1, 1, -1)
EndFunc   ;==>_CheckString

Also Bowmore I don't know why you need the Include File <File.au3>? ;)

Edited by guinness

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites
xdp22

It's already done guys, but thanks :) your version lot better.

Edited by xdp22

Share this post


Link to post
Share on other sites
guinness

The difference between your version and our versions is that it can be called multiple times, whereas with yours it is only executed once, hence the reason why Functions can save you alot of time.


UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites
Bowmore

Also Bowmore I don't know why you need the Include File <File.au3>? :)

You're correct It's not needed. I forgot to delete from the script cut this example from. Edited by Bowmore

"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

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.