本站源代码
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.

46 lines
738B

  1. package match
  2. import (
  3. "fmt"
  4. "github.com/gobwas/glob/util/strings"
  5. )
  6. type Any struct {
  7. Separators []rune
  8. }
  9. func NewAny(s []rune) Any {
  10. return Any{s}
  11. }
  12. func (self Any) Match(s string) bool {
  13. return strings.IndexAnyRunes(s, self.Separators) == -1
  14. }
  15. func (self Any) Index(s string) (int, []int) {
  16. found := strings.IndexAnyRunes(s, self.Separators)
  17. switch found {
  18. case -1:
  19. case 0:
  20. return 0, segments0
  21. default:
  22. s = s[:found]
  23. }
  24. segments := acquireSegments(len(s))
  25. for i := range s {
  26. segments = append(segments, i)
  27. }
  28. segments = append(segments, len(s))
  29. return 0, segments
  30. }
  31. func (self Any) Len() int {
  32. return lenNo
  33. }
  34. func (self Any) String() string {
  35. return fmt.Sprintf("<any:![%s]>", string(self.Separators))
  36. }
上海开阖软件有限公司 沪ICP备12045867号-1