mixim Posted May 8, 2021 Share Posted May 8, 2021 Hi, i need some help. How can I get the sequence number of the "0"s here. $string = "17000220064602" I'm trying to reach this >>>< 3 - 4 - 5 - 8 - 9 - 13 Link to comment Share on other sites More sharing options...
TheXman Posted May 8, 2021 Share Posted May 8, 2021 (edited) One way to do it would be to split the char string into an array of chars (StringSplit). Then, spin through the array of chars looking for the char of interest. Spoiler example() Func example() Const $CHAR_STRING = "17000220064602" Local $aChars = StringSplit($CHAR_STRING, "") ;Split char string into array of chars ;For each char in the array For $i = 1 To $aChars[0] If $aChars[$i] = "0" Then ConsoleWrite("Char found at position " & $i & @CRLF) Next EndFunc Console output: Char found at position 3 Char found at position 4 Char found at position 5 Char found at position 8 Char found at position 9 Char found at position 13 Edited May 8, 2021 by TheXman Fixed For/Next loop CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
mixim Posted May 8, 2021 Author Share Posted May 8, 2021 (edited) 1 hour ago, TheXman said: One way to do it would be to split the char string into an array of chars (StringSplit). Then, spin through the array of chars looking for the char of interest. Reveal hidden contents example() Func example() Const $NUMBER_SEQUENCE = "17000220064602" Local $aChars = StringSplit($NUMBER_SEQUENCE, "") ;Split char string into array of chars ;For each char in the array For $i = 0 To $aChars[0] If $aChars[$i] = "0" Then ConsoleWrite("Char found at position " & $i & @CRLF) Next EndFunc Console output: Char found at position 3 Char found at position 4 Char found at position 5 Char found at position 8 Char found at position 9 Char found at position 13 I tried with StringSplit but couldn't it. I could only reach the first 0 😢 Edited May 8, 2021 by mixim Link to comment Share on other sites More sharing options...
TheXman Posted May 8, 2021 Share Posted May 8, 2021 (edited) Click on "Reveal hidden contents" in my previous post. And next time, don't say what didn't work without showing it. Edited May 8, 2021 by TheXman mixim 1 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Gianni Posted May 8, 2021 Share Posted May 8, 2021 ... or also by scanning each char of the string using string functions $sString = "17000220064602" For $i = 1 To StringLen($sString) If StringMid($sString, $i, 1) = "0" Then ConsoleWrite($i & " - ") Next mixim 1 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
mixim Posted May 8, 2021 Author Share Posted May 8, 2021 @TheXman ok, i got it I thank you very much friends. These helped me.❤️ TheXman 1 Link to comment Share on other sites More sharing options...
Subz Posted May 8, 2021 Share Posted May 8, 2021 You could also use _ArrayFindAll #include <Array.au3> $sString = "17000220064602" $aString = StringSplit($sString, "", 1) $aResult = _ArrayFindAll($aString, "0") _ArrayDisplay($aResult) mixim 1 Link to comment Share on other sites More sharing options...
JockoDundee Posted May 8, 2021 Share Posted May 8, 2021 @subz gets the trophy, everybody else gets the love Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
Musashi Posted May 8, 2021 Share Posted May 8, 2021 18 minutes ago, JockoDundee said: @subz gets the trophy, everybody else gets the love Some people will be honoured, others will be adored. (I hope this pun will not get lost in translation) FrancescoDiMuro 1 "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." 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