Can anyone point to best algorithm for substring search in another string? or search for a char array in another char array?
4 Answers
The best from what point of view? Knuth-Morris-Pratt is a good one. You can find more of them discussed on the Wikipedia entry for string searching algorithms.
Comments
It depends on what types of searching you are doing. Specific substring over a specific string? Specific substring over many different strings? Many different substrings over a specific string?
Here's a popular algorithm for a specific substring over many different strings.
Comments
This strstr() implementation seems pretty slick.
1 Comment
osgx
It is strstr.c for alpha. Which algorithm it uses? Which algorithm is used in x86 (or _64) for strstr?