MCPcopy Create free account
hub / github.com/cel-expr/cel-go / regexSearch

Function regexSearch

ext/regex.go:393–398  ·  view source on GitHub ↗

regexSearch is the cost of matching pattern against target: the product of their lengths.

(target, pattern cost.QuantityExpr)

Source from the content-addressed store, hash-verified

391
392// regexSearch is the cost of matching pattern against target: the product of their lengths.
393func regexSearch(target, pattern cost.QuantityExpr) cost.QuantityExpr {
394 return cost.Mul(
395 cost.Scale(cost.Sum(cost.Length(target), cost.Const(1)), cost.StringTraversalCostFactor),
396 cost.Scale(cost.Sum(cost.Length(pattern), cost.Const(1)), cost.RegexStringLengthCostFactor),
397 )
398}
399
400// regexExtractCostModel models regex.extract: it searches the target, and returns an optional
401// holding the first match or capture group, a part of the target. The result is charged as the

Callers 3

regexExtractCostModelFunction · 0.85
regexExtractAllCostModelFunction · 0.85
regexReplaceCostModelFunction · 0.85

Calls 5

MulFunction · 0.92
ScaleFunction · 0.92
SumFunction · 0.92
LengthFunction · 0.92
ConstFunction · 0.92

Tested by

no test coverage detected