Stop matching after the end of the input sequence was reached.

#KT-8763 Fixed
This commit is contained in:
Ilya Gorbunov
2015-08-10 20:44:16 +03:00
committed by Sergey Mashkov
parent c74577951e
commit 15d69499d0
2 changed files with 36 additions and 26 deletions
+9
View File
@@ -54,6 +54,15 @@ class RegexTest {
assertEquals(listOf(0..2, 4..6, 8..10), matches.map { it.range }.toList())
}
test fun matchAllSequence() {
val input = "test"
val pattern = ".*".toRegex()
val matches = pattern.matchAll(input).toList()
assertEquals(input, matches[0].value)
assertEquals(input, matches.joinToString("") { it.value })
assertEquals(2, matches.size())
}
test fun matchGroups() {
val input = "1a 2b 3c"
val pattern = "(\\d)(\\w)".toRegex()