Find Sub-string in Longer String

These may display very funny for some people because of the use of the pre html tag. Unfortunately, line breaks will break clips … so that’s life.

In this case, if you enter a sub-string you want to find in the first box, say 13a, and then enter a string in the second box, say 13a79oiuj13Anjh, you will find the substring twice with case insensitive and just once with case sensative searching.

; find every instance of string "a"
; in longer string "b"
; by don at
^!Set %x%=^?[string you want to find]
^!Set %y%=^?[string you want to find it in]
^!Set %z%=^?[Case Sensitive=True|_False]
^!Set %xa%=^$StrPos("^%x%";"^%y%";^%z%)$
^!If ^%xa%=0 Finish
^!Info String Found Starting At: ^%xa%

^!Set %xb%=^$StrPosMid("^%x%";"^%y%";^$Calc(^%xa%+1)$;^%z%)$
^!If ^%xb%=0 Finish
^!Info String Found Starting At: ^%xb%
^!Set %xa%=^%xb%
^!GoTo Loop

^!Info String Not Found
^!GoTo End

Leave a Reply

Recent Posts