MCPcopy Create free account
hub / github.com/g3n/engine / StrFind

Function StrFind

text/str.go:19–38  ·  view source on GitHub ↗

StrFind returns the start and length of the rune at the specified position in the string

(s string, pos int)

Source from the content-addressed store, hash-verified

17// StrFind returns the start and length of the rune at the
18// specified position in the string
19func StrFind(s string, pos int) (start, length int) {
20
21 count := 0
22 for index := range s {
23 if count == pos {
24 start = index
25 count++
26 continue
27 }
28 if count == pos+1 {
29 length = index - start
30 break
31 }
32 count++
33 }
34 if length == 0 {
35 length = len(s) - start
36 }
37 return start, length
38}
39
40// StrRemove removes the rune from the specified string and position
41func StrRemove(s string, col int) string {

Callers 2

StrRemoveFunction · 0.85
StrInsertFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected