Find multiple occurrence string

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • Hi,

    I searched the forum but did not find anything that would help me on this, so here it is :

    I'm tiring to build a list/an array with all the character position of a specific substring in a string. For example, it the following : " mfiduA dkdjfA dkA sd " I would like to create an array which would contains [6, 13, 17], which are all the position of each "A" occurrence in that string.

    I basically know how the "Find ( STRING, SUBSTRING, INDEX) works, but I'm only able to use it in a case with a single occurrence of the substring (which would only return a single number).

    So is there an other way to return all positions of all occurrence of a substring ?

    Thanks !

  • You can probably do that with the String Parser object.

    Alternatively, you could perhaps copy the string to a temporary alterable string, then use a fastloop to delete each "A" as you find it, then search again for the next "A". I'm not at my PC so don't know if I've got the syntax right, but I'd guess it would be something like this:

    If the first one is at 6, then copy Right$(yourText, Length$(yourText) - 6)) into the temporary alterable string. Then search that alterable string for the next one. And add 6 to the result to make up for the missing characters. And repeat until there are no more "A"s.

    Please login to see this link.
    My Fusion Tools: Please login to see this link. | Please login to see this link. | Please login to see this link.

  • The built in "find" function takes an argument that specifies the point from which to search, so it's pretty simple to just do repeated searches, starting each one from the previous match, and stopping when there are no more matches.

    + Start of Frame
    -> Start fastloop "find", -1 times

    + On loop "find"
    -> Set Match to Find("blah blah blah", "blah", searchFrom)

    + On loop "find"
    + Match = -1
    -> Stop loop "find"

    + On loop "find"
    + Match > -1
    -> Set searchFrom to Match + 1
    -> Array: Write Match to totalMatches
    -> Add 1 to totalMatches

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!