Use new API for findAllMatches

master
Aadhavan Srinivasan 2 weeks ago
parent c8613c1ba2
commit 644ed15af0

@ -122,13 +122,21 @@ func (s State) checkAssertion(str []rune, idx int) bool {
// 2. Run it on a subset of the test string, that ends after the current index in the string // 2. Run it on a subset of the test string, that ends after the current index in the string
// 3. Based on the kind of lookaround (and the indices we get), determine what action to take. // 3. Based on the kind of lookaround (and the indices we get), determine what action to take.
startState := s.lookaroundNFA startState := s.lookaroundNFA
var strToMatch []rune var runesToMatch []rune
var strToMatch string
if s.assert == PLA || s.assert == NLA { if s.assert == PLA || s.assert == NLA {
strToMatch = str[idx:] runesToMatch = str[idx:]
} else { } else {
strToMatch = str[:idx] runesToMatch = str[:idx]
} }
matchIndices := findAllMatches(startState, strToMatch, startState.lookaroundNumCaptureGroups)
if len(runesToMatch) == 0 {
strToMatch = ""
} else {
strToMatch = string(runesToMatch)
}
matchIndices := findAllMatches(Reg{startState, startState.lookaroundNumCaptureGroups}, strToMatch)
numMatchesFound := 0 numMatchesFound := 0
for _, matchIdx := range matchIndices { for _, matchIdx := range matchIndices {

Loading…
Cancel
Save