From 13a57a4347a846f7903f50026a83b55444dfcd74 Mon Sep 17 00:00:00 2001 From: Aadhavan Srinivasan Date: Mon, 28 Oct 2024 00:58:10 -0400 Subject: [PATCH] Stricter check for adding zero-length match at end of string --- matching.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matching.go b/matching.go index 52de354..52e8b04 100644 --- a/matching.go +++ b/matching.go @@ -32,7 +32,7 @@ func findAllMatchesHelper(start *State, str string, indices []matchIndex, offset // 'Base case' - exit if string is empty. if len(str) == 0 { // 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}) } return indices