2015-12-24 17:54:54 +03:00
|
|
|
package match
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2015-12-25 19:40:36 +03:00
|
|
|
"strings"
|
2015-12-24 17:54:54 +03:00
|
|
|
)
|
|
|
|
|
2015-12-25 19:40:36 +03:00
|
|
|
type Any struct {
|
2015-12-24 17:54:54 +03:00
|
|
|
Separators string
|
|
|
|
}
|
|
|
|
|
2015-12-25 19:40:36 +03:00
|
|
|
func (self Any) Match(s string) bool {
|
2015-12-24 17:54:54 +03:00
|
|
|
return strings.IndexAny(s, self.Separators) == -1
|
|
|
|
}
|
|
|
|
|
2015-12-25 19:40:36 +03:00
|
|
|
func (self Any) Search(s string) (i, l int, ok bool) {
|
2015-12-24 17:54:54 +03:00
|
|
|
if self.Match(s) {
|
|
|
|
return 0, len(s), true
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2015-12-25 19:40:36 +03:00
|
|
|
func (self Any) Kind() Kind {
|
2015-12-24 17:54:54 +03:00
|
|
|
if self.Separators == "" {
|
|
|
|
return KindMultipleSuper
|
|
|
|
} else {
|
|
|
|
return KindMultipleSeparated
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-25 19:40:36 +03:00
|
|
|
func (self Any) String() string {
|
2015-12-24 17:54:54 +03:00
|
|
|
return fmt.Sprintf("[multiple:%s]", self.Separators)
|
2015-12-25 19:40:36 +03:00
|
|
|
}
|