MustCompile compiles a regular expression pattern and panics if it fails. This is useful for patterns known to be valid at compile time. Example: var emailRegex = coregex.MustCompile(`[a-z]+@[a-z]+\.[a-z]+`)
(pattern string)
| 127 | // |
| 128 | // var emailRegex = coregex.MustCompile(`[a-z]+@[a-z]+\.[a-z]+`) |
| 129 | func MustCompile(pattern string) *Regex { |
| 130 | re, err := Compile(pattern) |
| 131 | if err != nil { |
| 132 | panic("regexp: Compile(`" + pattern + "`): " + err.Error()) |
| 133 | } |
| 134 | return re |
| 135 | } |
| 136 | |
| 137 | // CompilePOSIX is like Compile but restricts the regular expression to |
| 138 | // POSIX ERE (egrep) syntax and changes the match semantics to leftmost-longest. |