A little doubt on the intermediate textbook of programmers in the soft exam:
in the worst case, each unsuccessful match is the last character of the pattern string, which is not equal to the corresponding character in the main string, then the starting position of the new run in the main string is i-m+2.
where did this i-m+2 come from?
according to the simple string matching algorithm, it is not successful. The starting position of the next trip should be the next character of the main string.
assume that the main string is S, the length is n, the pattern string is P, and the length is m.
start with S [0], compare S and P
bit by bit, if the match fails, start with S [1], and then S [2] S [3].