MCPcopy Create free account
hub / github.com/Mrs4s/six-cli / ShellMatch

Function ShellMatch

models/tools.go:90–117  ·  view source on GitHub ↗
(str, p string)

Source from the content-addressed store, hash-verified

88}
89
90func ShellMatch(str, p string) bool {
91 var (
92 j, i, star, last int
93 rs = []rune(str)
94 rp = []rune(p)
95 )
96
97 for i < len(rs) {
98 if j < len(rp) && (rs[i] == rp[j] || rp[j] == '?') {
99 i++
100 j++
101 } else if j < len(rp) && rp[j] == '*' {
102 j++
103 last = i
104 star = j
105 } else if star != 0 {
106 last++
107 i = last
108 j = star
109 } else {
110 return false
111 }
112 }
113 for j < len(rp) && rp[j] == '*' {
114 j++
115 }
116 return j == len(rp)
117}
118
119func SelectStrings(arr []string, selector func(string) string) []string {
120 var res []string

Callers 2

FindMethod · 0.92
ListMethod · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected