Find a string

  • + 0 comments

    Just to point out, there is a slight optimization in the loop. One can stop after len(s) - len(sub) + 1 since the remaining part of s at that point is shorter than the pattern to match and thus can't possibly match.