Proposals Unofficial Go proposal tracker

Add iterator versions of regexp FindAll methods and Split

#61902 · regexp · medium impact · Implemented in Go 1.28 ·

Regexp's FindAll* methods collect every match into a slice, even when the caller only wants to loop over the matches or stop early. This proposal adds iterator versions that return matches one at a time, without building the slice.

Each FindAll* method gets an equivalent named by dropping the Find prefix: All, AllIndex, AllString, AllSubmatch, etc. Each returns an iter.Seq of the type the matching non-All method returns. For example, AllString returns iter.Seq[string] and AllStringSubmatch returns iter.Seq[[]string]. A new SplitSeq method mirrors Split, the same way strings.SplitSeq mirrors strings.Split.

re := regexp.MustCompile(`\d+`)
for m := range re.AllString("a1 b22 c333") {
    fmt.Println(m) // 1, 22, 333
}

for part := range re.SplitSeq("a1b22c") {
    fmt.Println(part) // a, b, c
}
Proposal
#61902 by rsc
Status
Implemented on Oct 6, 2026
Release
Go 1.28
Impact
medium
Area
regexp