diff --git a/regexp.go b/regexp.go index fba1e33..7c7b01d 100644 --- a/regexp.go +++ b/regexp.go @@ -235,6 +235,9 @@ func (re *Regexp) getRunesAndStart(s string, startAt int) ([]rune, int) { ret[i] = r i++ } + if startAt == len(s) { + runeIdx = i + } return ret[:i], runeIdx } diff --git a/regexp_test.go b/regexp_test.go index f2a507d..f4246a5 100644 --- a/regexp_test.go +++ b/regexp_test.go @@ -877,6 +877,17 @@ func TestAlternationConstruct_Matches(t *testing.T) { } } +func TestStartAtEnd(t *testing.T) { + re := MustCompile("(?:)", 0) + m, err := re.FindStringMatchStartingAt("t", 1) + if err != nil { + t.Fatal(err) + } + if m == nil { + t.Fatal("Expected match") + } +} + func TestParserFuzzCrashes(t *testing.T) { var crashes = []string{ "(?'-", "(\\c0)", "(\\00(?())", "[\\p{0}", "(\x00?.*.()?(()?)?)*.x\xcb?&(\\s\x80)", "\\p{0}", "[0-[\\p{0}",