regexSearch is the cost of matching pattern against target: the product of their lengths.
(target, pattern cost.QuantityExpr)
| 391 | |
| 392 | // regexSearch is the cost of matching pattern against target: the product of their lengths. |
| 393 | func 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 |
no test coverage detected