You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go.nvim/playground/sampleApp/pkg/findAllSubStr.go

29 lines
555 B
Go

package pkg
import (
"strings"
)
func FindAllSubStr(stack, niddle string) (result []int) {
stack = strings.ToLower(stack)
niddle = strings.ToLower(niddle)
for idx := 1; idx >= 0; {
if idx = strings.Index(stack, niddle); idx != -1 {
result = append(result, idx)
stack = stack[idx+1:]
}
}
return result
}
func FindSubStr(stack, niddle string) (result int) {
stack = strings.ToLower(stack)
niddle = strings.ToLower(niddle)
for idx := 1; idx >= 0; {
if idx = strings.Index(stack, niddle); idx != -1 {
return idx
}
}
return -1
}