MCPcopy Create free account
hub / github.com/brimdata/super / regexpPrefix

Function regexpPrefix

compiler/optimizer/pruner.go:188–201  ·  view source on GitHub ↗

regexpPrefix returns the prefix of the provided regular expression (if one exists) only if the regular expression matches the beginning of a string.

(s string)

Source from the content-addressed store, hash-verified

186// regexpPrefix returns the prefix of the provided regular expression (if one
187// exists) only if the regular expression matches the beginning of a string.
188func regexpPrefix(s string) string {
189 re, err := syntax.Parse(s, syntax.Perl)
190 if err != nil {
191 return ""
192 }
193 re = re.Simplify()
194 if re.Op == syntax.OpConcat &&
195 len(re.Sub) >= 2 &&
196 re.Sub[0].Op == syntax.OpBeginText &&
197 re.Sub[1].Op == syntax.OpLiteral {
198 return string(re.Sub[1].Rune)
199 }
200 return ""
201}
202
203func regexpMaxPrefix(s string) string {
204 b := []byte(s)

Callers 1

newMetadataPrunerFunction · 0.85

Calls 1

ParseMethod · 0.80

Tested by

no test coverage detected