diff --git a/nfa.go b/nfa.go index df9dbac..5566579 100644 --- a/nfa.go +++ b/nfa.go @@ -90,7 +90,8 @@ func (s State) checkAssertion(str []rune, idx int) bool { return idx == 0 } if s.assert == EOS { - return idx == len(str) + // Index is at the end of the string, or it points to the last character which is a newline + return idx == len(str) || (idx == len(str)-1 && str[len(str)-1] == '\n') } if s.assert == WBOUND { return isWordBoundary(str, idx)