Stricter check for adding zero-length match at end of string

master
Aadhavan Srinivasan 2 months ago
parent 4a30977d15
commit 13a57a4347

@ -32,7 +32,7 @@ func findAllMatchesHelper(start *State, str string, indices []matchIndex, offset
// 'Base case' - exit if string is empty. // 'Base case' - exit if string is empty.
if len(str) == 0 { if len(str) == 0 {
// If the start is a Kleene star, then it should also match an empty string. // If the start is a Kleene star, then it should also match an empty string.
if start.isKleene { if start.isKleene && start.isLast {
indices = append(indices, matchIndex{offset, offset}) indices = append(indices, matchIndex{offset, offset})
} }
return indices return indices

Loading…
Cancel
Save