Home | History | Annotate | Download | only in strings

Lines Matching refs:substr

26 // Index returns the index of the first instance of substr in s, or -1 if substr is not present in s.
27 func Index(s, substr string) int {
28 n := len(substr)
33 return IndexByte(s, substr[0])
35 if substr == s {
42 // Use brute force when s and substr both are small
44 return indexShortStr(s, substr)
46 c := substr[0]
60 if s[i:i+n] == substr {
69 r := indexShortStr(s[i:], substr)
78 return indexRabinKarp(s, substr)
81 // Count counts the number of non-overlapping instances of substr in s.
82 // If substr is an empty string, Count returns 1 + the number of Unicode code points in s.
83 func Count(s, substr string) int {
84 if len(substr) == 1 && cpu.X86.HasPOPCNT {
85 return countByte(s, byte(substr[0]))
87 return countGeneric(s, substr)