...
1 package match
2
3 import (
4 "fmt"
5 "github.com/gobwas/glob/util/strings"
6 )
7
8 type Any struct {
9 Separators []rune
10 }
11
12 func NewAny(s []rune) Any {
13 return Any{s}
14 }
15
16 func (self Any) Match(s string) bool {
17 return strings.IndexAnyRunes(s, self.Separators) == -1
18 }
19
20 func (self Any) Index(s string) (int, []int) {
21 found := strings.IndexAnyRunes(s, self.Separators)
22 switch found {
23 case -1:
24 case 0:
25 return 0, segments0
26 default:
27 s = s[:found]
28 }
29
30 segments := acquireSegments(len(s))
31 for i := range s {
32 segments = append(segments, i)
33 }
34 segments = append(segments, len(s))
35
36 return 0, segments
37 }
38
39 func (self Any) Len() int {
40 return lenNo
41 }
42
43 func (self Any) String() string {
44 return fmt.Sprintf("<any:![%s]>", string(self.Separators))
45 }
46
View as plain text