MCPcopy Create free account
hub / github.com/dlclark/regexp2 / findFixedDistanceStringLeftToRight

Function findFixedDistanceStringLeftToRight

runner.go:1651–1677  ·  view source on GitHub ↗
(r *Runner, literal []rune, distance int)

Source from the content-addressed store, hash-verified

1649}
1650
1651func findFixedDistanceStringLeftToRight(r *Runner, literal []rune, distance int) bool {
1652 if len(literal) == 0 {
1653 return true
1654 }
1655
1656 searchStart := r.Runtextpos + distance
1657 for searchStart <= r.Runtextend-len(literal) {
1658 offset := helpers.IndexOf(r.Runtext[searchStart:], literal)
1659 if offset < 0 {
1660 r.Runtextpos = r.Runtextend
1661 return false
1662 }
1663 literalIndex := searchStart + offset
1664 start := literalIndex - distance
1665 if start >= r.Runtextpos && hasRequiredLengthAt(r, start) {
1666 r.Runtextpos = start
1667 return true
1668 }
1669 if start > latestPossibleStart(r) {
1670 break
1671 }
1672 searchStart = literalIndex + 1
1673 }
1674
1675 r.Runtextpos = r.Runtextend
1676 return false
1677}
1678
1679func findFixedDistanceSetsLeftToRight(r *Runner, sets []syntax.FixedDistanceSet) bool {
1680 if len(sets) == 0 || sets[0].Set == nil {

Callers 1

findFirstCharOptimizedFunction · 0.85

Calls 3

IndexOfFunction · 0.92
hasRequiredLengthAtFunction · 0.85
latestPossibleStartFunction · 0.85

Tested by

no test coverage detected