From 315f68df12d4a01fdee25fc48a67f2d4c932331c Mon Sep 17 00:00:00 2001 From: Aadhavan Srinivasan Date: Thu, 31 Oct 2024 17:55:41 -0400 Subject: [PATCH] Fixed typo --- matching.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/matching.go b/matching.go index 94a6ea0..11ddaf3 100644 --- a/matching.go +++ b/matching.go @@ -150,7 +150,7 @@ func findAllMatchesHelper(start *State, str string, indices []matchIndex, offset tempIndices, _ = unique_append(tempIndices, matchIndex{startIdx, endIdx}) } } - if assertionFailed && numStatesMatched == 0 { // Nothing has matched and an assertion has failed - bort + if assertionFailed && numStatesMatched == 0 { // Nothing has matched and an assertion has failed - abort if i == startingFrom { i++ } @@ -208,10 +208,13 @@ func findAllMatchesHelper(start *State, str string, indices []matchIndex, offset tempStates = nil for _, state := range currentStates { - // Only add the match if the start index is in bounds + // Only add the match if the start index is in bounds. If the state has an assertion, + // make sure the assertion checks out. if state.isLast && startIdx < len(str) { - endIdx = i - tempIndices, _ = unique_append(tempIndices, matchIndex{startIdx, endIdx}) + if state.assert == NONE || state.checkAssertion([]rune(str), len(str)) { + endIdx = i + tempIndices, _ = unique_append(tempIndices, matchIndex{startIdx, endIdx}) + } } } // Get the maximum index-range from the list