mirror of https://github.com/go-gitea/gitea
Git with a cup of tea, painless self-hosted git service
Mirror for internal git.with.parts use
https://git.with.parts
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
563 B
39 lines
563 B
package strings
|
|
|
|
import (
|
|
"strings"
|
|
"unicode/utf8"
|
|
)
|
|
|
|
func IndexAnyRunes(s string, rs []rune) int {
|
|
for _, r := range rs {
|
|
if i := strings.IndexRune(s, r); i != -1 {
|
|
return i
|
|
}
|
|
}
|
|
|
|
return -1
|
|
}
|
|
|
|
func LastIndexAnyRunes(s string, rs []rune) int {
|
|
for _, r := range rs {
|
|
i := -1
|
|
if 0 <= r && r < utf8.RuneSelf {
|
|
i = strings.LastIndexByte(s, byte(r))
|
|
} else {
|
|
sub := s
|
|
for len(sub) > 0 {
|
|
j := strings.IndexRune(s, r)
|
|
if j == -1 {
|
|
break
|
|
}
|
|
i = j
|
|
sub = sub[i+1:]
|
|
}
|
|
}
|
|
if i != -1 {
|
|
return i
|
|
}
|
|
}
|
|
return -1
|
|
}
|
|
|