Home | History | Annotate | Download | only in strings

Lines Matching refs:pattern

13 	// pattern is the string that we are searching for in the text.
14 pattern string
16 // badCharSkip[b] contains the distance between the last byte of pattern
17 // and the rightmost occurrence of b in pattern. If b is not in pattern,
18 // badCharSkip[b] is len(pattern).
26 // that the suffix pattern[i+1:] matches, but the byte pattern[i] does
29 // 1. The matched suffix occurs elsewhere in pattern (with a different
32 // example, the pattern "mississi" has the suffix "issi" next occurring
36 // 2. If the matched suffix does not occur elsewhere in pattern, then the
40 // suffix. For example, in the pattern "abcxxxabc", when the first
42 // suffix "xxabc" is not found elsewhere in the pattern. However, its
43 // rightmost "abc" (at position 6) is a prefix of the whole pattern, so
48 func makeStringFinder(pattern string) *stringFinder {
50 pattern: pattern,
51 goodSuffixSkip: make([]int, len(pattern)),
53 // last is the index of the last character in the pattern.
54 last := len(pattern) - 1
57 // Bytes not in the pattern can skip one pattern's length.
59 f.badCharSkip[i] = len(pattern)
65 f.badCharSkip[pattern[i]] = last - i
70 // pattern.
73 if HasPrefix(pattern, pattern[i+1:]) {
79 // Second pass: find repeats of pattern's suffix starting from the front.
81 lenSuffix := longestCommonSuffix(pattern, pattern[1:i+1])
82 if pattern[i-lenSuffix] != pattern[last-lenSuffix] {
100 // next returns the index in text of the first occurrence of the pattern. If
101 // the pattern is not found, it returns -1.
103 i := len(f.pattern) - 1
106 j := len(f.pattern) - 1
107 for j >= 0 && text[i] == f.pattern[j] {