|
|
@ -108,11 +108,15 @@ func (s State) checkAssertion(str []rune, idx int) bool {
|
|
|
|
return true
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if s.assert == SOS {
|
|
|
|
if s.assert == SOS {
|
|
|
|
return idx == 0
|
|
|
|
// Single-line mode: Beginning of string
|
|
|
|
|
|
|
|
// Multi-line mode: Previous character was newline
|
|
|
|
|
|
|
|
return idx == 0 || (multilineMode && (idx > 0 && str[idx-1] == '\n'))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if s.assert == EOS {
|
|
|
|
if s.assert == EOS {
|
|
|
|
|
|
|
|
// Single-line mode: End of string
|
|
|
|
|
|
|
|
// Multi-line mode: current character is newline
|
|
|
|
// Index is at the end of the string, or it points to the last character which is a newline
|
|
|
|
// 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')
|
|
|
|
return idx == len(str) || (multilineMode && str[idx] == '\n')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if s.assert == WBOUND {
|
|
|
|
if s.assert == WBOUND {
|
|
|
|
return isWordBoundary(str, idx)
|
|
|
|
return isWordBoundary(str, idx)
|
|
|
|