Jump to content

Recommended Posts

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 post
Share on other sites
Posted (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 by TheXman
Fixed For/Next loop
Link to post
Share on other sites
Posted (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 by mixim
Link to post
Share on other sites
Posted (edited)

Click on "Reveal hidden contents" in my previous post.

And next time, don't say what didn't work without showing it.

Edited by TheXman
Link to post
Share on other sites
18 minutes ago, JockoDundee said:

@subz gets the trophy, everybody else gets the love :)

Some people will be honoured, others will be adored. :lol:

(I hope this pun will not get lost in translation)

Musashi-C64.png

"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 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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...