Multiple search of a substring in a string

Hi, i search a better block to achieve this (not this ugly block)


I think i can use the split block to achieve the task but i can't figure out...

first of all, no need do specify case sensitivity, thats a setting.

If it is important for you :yes

Yeah, it's really hard to deal with overlapping partial matches, such as searching for "sis" in "Mississippi." I think you may be asking for too much from SPLIT. In your example, it seems to me that the right answer is not (1,5) but rather (1,2,5,6).

I mean, it just seemed unessecary, but I am right now working on a cleaner version of the block.

basically i need to search for the occurrence of a single character like the 1st example
(another example: where's the a in alabama: 1,3,5,7)

the 1st blank is an "a": so it is at position 1 (length of "a" is 1)
there is an "a" between "l" and "b" so 1+lenght of "l" +1(the next char) =3
there is an "a" between "b" and "m" so 3+lenght of "b" +1(the next char) =5
and so on...

I agree, SPLIT is perfect for single characters -- although it doesn't tell you the actual position indices, so you have to do that calculation. It's just multiple characters that makes it hard, because of the overlap cases.

I don't know, it's a matter of point of view.
The question is: when I found a substring, do I continue the search at the next character or after the previously found substring...

in microsoft word:


in wordpad:

image
image
image
image
image
notepad is like microsoft word
chrome is like microsoft word
edge is like microsoft word
firefox is like microsoft word

Is this what you want?


If you don't want positions to overlap, you can use this instead


untitled script pic(30)

this uses HOFS and is extremely fast and concise!

Not that obvious use of the variadic as optional parameters to avoid extra helper

Well obviously whatever Microsoft Word does has to be wrong! ;~P

Yes.

There's an error in your 2nd block: it should return (1,4)


The 1st one seem ok

Impressive speed !

idk why, your's is very slow in a big string; maybe because you use recursion with the big string as input over and over (? and it take so much memory?).

try it with:
image

(ego-lay_atman-bay do it in 150ms)

thank you! after compiling the map blocks (See my old post, I edited it) its now even faster!

That's correct, because the string you're searching is ..a... with 2 dots at the beginning instead of 3. However, I did notice that it is indeed wrong when searching for ...

remove hat DEV script pic(2)
I think this is the best one so far, no variables and only reporters so it is very fast (but I'm not sure if its as fast as my old one)