Searching for parts of a string
Posted: Wed Apr 18, 2012 1:44 am
Is there any built-in function to search for parts of a string? If we, for example, have the string "fivewordswrittenasone" and want to search to see if the substring "words" can be found therein? That is, I am looking for a function that relates to @wfind as @mid relates to @wmid and thus would return the same as the code below.
Code: Select all
%str="fivewordswrittenasone"
%sub="words"
!strlen=@len(%str)
!sublen=@len(%sub)
for !i=1 to !strlen-!sublen+1
%piece=@mid(%str,!i,!sublen)
if %piece=%sub then
%return=%piece
exitloop
endif
next