2016-01-08 20:14:31 +03:00
|
|
|
package match
|
|
|
|
|
2016-01-09 02:34:41 +03:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"unicode/utf8"
|
|
|
|
)
|
2016-01-08 20:14:31 +03:00
|
|
|
|
|
|
|
type Max struct {
|
|
|
|
Limit int
|
|
|
|
}
|
|
|
|
|
|
|
|
func (self Max) Match(s string) bool {
|
2016-01-09 02:34:41 +03:00
|
|
|
return utf8.RuneCountInString(s) <= self.Limit
|
|
|
|
}
|
|
|
|
|
|
|
|
func (self Max) Len() int {
|
|
|
|
return -1
|
2016-01-08 20:14:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func (self Max) Search(s string) (int, int, bool) {
|
|
|
|
return 0, 0, false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (self Max) Kind() Kind {
|
|
|
|
return KindMax
|
|
|
|
}
|
|
|
|
|
|
|
|
func (self Max) String() string {
|
|
|
|
return fmt.Sprintf("[max:%d]", self.Limit)
|
|
|
|
}
|