How do I find the total occurrence of something?

How can I find the total number of times a string occurs in a specific string? For example:
s = “abcabcd”
t = find occurrence of “d” in s
print(t) # Will output 1 because “d” appears only once while “a” appears twice."

Note:
I want to do this without any external devices(properties, loops, etc.), only solutions with block code are what I look for.

Thank you.

I might have a method for having ALOT of memory, but if no external devices, i dont think its possible

What do you mean by

My problem can easily be solved utilizing a property and a counter, but those are “external-devices”, at least within my system(the trigger itself). I could also use loops, but I don’t want external-processing(events that occur outside of the system and that affect the system itself, loops usually require channels or other external events).

maybe I’m dum but it would be easier if you had a text property that set the value “abcabcd”, and then have another trigger use block code to find the occurence of d

like this maybe



Maybe work on this code more?
Screenshot 2025-03-17 9.55.50 AM
this is the best I can do

1 Like

and maybe you could put in another code that also finds last occurrence of “d” but this would only work in a number of situations.

Thanks for trying to help, but I believe I have found a solution:

1 Like