MCPcopy Create free account
hub / github.com/sergi/go-diff / lastIndexOf

Function lastIndexOf

diffmatchpatch/stringutil.go:47–56  ·  view source on GitHub ↗

lastIndexOf returns the last index of pattern in str, starting at str[i].

(str string, pattern string, i int)

Source from the content-addressed store, hash-verified

45
46// lastIndexOf returns the last index of pattern in str, starting at str[i].
47func lastIndexOf(str string, pattern string, i int) int {
48 if i < 0 {
49 return -1
50 }
51 if i >= len(str) {
52 return strings.LastIndex(str, pattern)
53 }
54 _, size := utf8.DecodeRuneInString(str[i:])
55 return strings.LastIndex(str[:i+size], pattern)
56}
57
58// runesIndexOf returns the index of pattern in target, starting at target[i].
59func runesIndexOf(target, pattern []rune, i int) int {

Callers 2

TestLastIndexOfFunction · 0.85
MatchBitapMethod · 0.85

Calls

no outgoing calls

Tested by 1

TestLastIndexOfFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…