evkaky
05/11/2017, 7:31 AMval str = "text here 123 and more text 456"
val regex = Regex("[0-9]+")
way 1)
var matchRes = regex.find(str)
while (matchRes != null) {
println(matchRes.value)
matchRes = matchRes.next()
}
way 2)
val matchRes = regex.findAll(str)
for (i in matchRes) {
println(i.value)
}
What’s the difference? May be matchRes.next() is not lazy, and for (i in matchRes) { is?