MCPcopy Create free account
hub / github.com/coregx/coregex / MustCompile

Function MustCompile

regex.go:129–135  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

127//
128// var emailRegex = coregex.MustCompile(`[a-z]+@[a-z]+\.[a-z]+`)
129func 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.

Callers 15

TestGoAWK_MatchPatternFunction · 0.92
TestGoAWK_SplitPatternFunction · 0.92
TestGoAWK_SubPatternFunction · 0.92
BenchmarkGoAWK_MatchFunction · 0.92
BenchmarkGoAWK_SplitFunction · 0.92
BenchmarkGoAWK_SubFunction · 0.92
BenchmarkGoAWK_NoMatchFunction · 0.92
BenchmarkGoAWK_LongestFunction · 0.92
ExampleMustCompileFunction · 0.92
ExampleRegex_FindFunction · 0.92

Calls 2

CompileFunction · 0.70
ErrorMethod · 0.45

Tested by 15

TestGoAWK_MatchPatternFunction · 0.74
TestGoAWK_SplitPatternFunction · 0.74
TestGoAWK_SubPatternFunction · 0.74
BenchmarkGoAWK_MatchFunction · 0.74
BenchmarkGoAWK_SplitFunction · 0.74
BenchmarkGoAWK_SubFunction · 0.74
BenchmarkGoAWK_NoMatchFunction · 0.74
BenchmarkGoAWK_LongestFunction · 0.74
ExampleMustCompileFunction · 0.74
ExampleRegex_FindFunction · 0.74