I am splitting a string by a repeatable delimiter, and am also intended to keep the delimiters as well.
val str = "xxoooooooxxoxoxooooo"
val reg = Regex("(?<=x+)|(?=x+)")
var list = str.split(reg)
println(list)
The output is [, x, x, ooooooo, x, x, o, x, o, x, ooooo]
, though I would like to get
[xx, ooooooo, xx, o, x, o, x, ooooo]