ParsePattern parses a string into a [Pattern] Rules: - Components separated by '/' - Each component is non-empty - Only characters A-Z, a-z, 0-9, '.', '-', '_' or '*' - No leading, trailing, or double slashes - Asterisks rules: - '*' cannot be mixed with other characters in the same component - ther
(s string)
| 122 | // - '*' cannot be mixed with other characters in the same component |
| 123 | // - there can be no more than two '*' per component |
| 124 | func ParsePattern(s string) (Pattern, error) { |
| 125 | if !validPattern(s) { |
| 126 | return nil, ErrInvalidPattern |
| 127 | } |
| 128 | return pattern(s), nil |
| 129 | } |
| 130 | |
| 131 | // MustParsePattern parses a string into a [Pattern] like with [ParsePattern], |
| 132 | // however, it panics when a validation error occurs. |