https://kotlinlang.org logo
#stdlib
Title
# stdlib
d

DownloadPizza

12/10/2023, 3:44 PM
I ran into an annoyance where Regex findAll did not match overlapping parts. I propose to add a findAllWithOverlap defined as follows:
Copy code
fun findAllWithOverlap(input: CharSequence, startIndex: Int = 0): Sequence<MatchResult> {
     if (startIndex < 0 || startIndex > input.length) {
         throw IndexOutOfBoundsException("Start index out of bounds: $startIndex, input length: ${input.length}")
    }  
return generateSequence({ find(input, startIndex) }, { find(input, it.range.first + 1) })
 }