Find substring 'substr' in string 'str'
Anonym
A brute-force substring search algorithm checks all possible positions: 1 function Search(string s[1..n], string sub[1..m]) 2 for i from 1 to n-m+1 3 for j from 1 to m 4 if s[i+j-1] ? sub[j] 5 jump to next iteration of outer loop 6 return i 7 return