ParseNamePattern parses a pattern string and returns a Matcher. It recognizes glob patterns (with "glob:" prefix), regular expressions (with "regex:" or "regexp:" prefix), and exact string matches (without any prefix).
(pattern string)
| 28 | // It recognizes glob patterns (with "glob:" prefix), regular expressions (with |
| 29 | // "regex:" or "regexp:" prefix), and exact string matches (without any prefix). |
| 30 | func ParseNamePattern(pattern string) (Matcher, error) { |
| 31 | switch { |
| 32 | case strings.HasPrefix(pattern, globPrefix): |
| 33 | return NewGlobPattern(strings.TrimPrefix(pattern, globPrefix)) |
| 34 | case strings.HasPrefix(pattern, regexPrefix): |
| 35 | return NewRegexpMatcher(strings.TrimPrefix(pattern, regexPrefix)) |
| 36 | case strings.HasPrefix(pattern, regexpPrefix): |
| 37 | return NewRegexpMatcher(strings.TrimPrefix(pattern, regexpPrefix)) |
| 38 | default: |
| 39 | return NewExactMatcher(pattern) |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | // ParsePathPattern parses a pattern string and returns a Matcher. |
| 44 | // It recognizes glob patterns (with "glob:" prefix), regular expressions (with |