I have this string with non-unique elements in it, and I need to find out the positions of a particular element:
e.g.,
Code: Select all
%names = "John Paul Andrew John John Tom"Tchaithonov
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
Code: Select all
%names = "John Paul Andrew John John Tom"Code: Select all
subroutine local wfindall(string result, string src, string target)
string srctemp = src
result = "" ' initialize
' initialize recursion
!found = 0
!posit= 0
!try = @wfind(srctemp, target) ' get the first match
' recursive loop
while (!try <> 0)
!found = !found + 1
result = result + " " + @str(!try + !posit) ' accumulate the result
srctemp = @wmid(srctemp, !try+1) ' get the remainder string
!posit= !posit + !try ' increment the number of trimmed
!try = @wfind(srctemp, target) ' look for the next
wend
result = @trim(result) ' cleanup
endsubCode: Select all
string result
call wfindall(result, %names, "John")Users browsing this forum: No registered users and 2 guests