Accounted for last character being a newline when checking for EOS (we can be at the second-last character if the last one is a newline
This commit is contained in:
3
nfa.go
3
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)
|
||||
|
Reference in New Issue
Block a user