MCPcopy Create free account
hub / github.com/zeromicro/go-zero / splitBy

Method splitBy

tools/goctl/util/stringx/string.go:98–121  ·  view source on GitHub ↗

it will not ignore spaces

(fn func(r rune) bool, remove bool)

Source from the content-addressed store, hash-verified

96
97// it will not ignore spaces
98func (s String) splitBy(fn func(r rune) bool, remove bool) []string {
99 if s.IsEmptyOrSpace() {
100 return nil
101 }
102 var list []string
103 buffer := new(bytes.Buffer)
104 for _, r := range s.source {
105 if fn(r) {
106 if buffer.Len() != 0 {
107 list = append(list, buffer.String())
108 buffer.Reset()
109 }
110 if !remove {
111 buffer.WriteRune(r)
112 }
113 continue
114 }
115 buffer.WriteRune(r)
116 }
117 if buffer.Len() != 0 {
118 list = append(list, buffer.String())
119 }
120 return list
121}
122
123func ContainsAny(s string, runes ...rune) bool {
124 if len(runes) == 0 {

Callers 2

ToCamelMethod · 0.95
ToSnakeMethod · 0.95

Calls 4

IsEmptyOrSpaceMethod · 0.95
LenMethod · 0.80
ResetMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected