Rename split method to splitBy and revive old split implementation interpreting parameter as regex to provide the migration path.
This commit is contained in:
committed by
Ilya Gorbunov
parent
b10d869cd7
commit
b3165ac771
@@ -479,7 +479,7 @@ class CollectionTest {
|
||||
}
|
||||
|
||||
test fun decomposeSplit() {
|
||||
val (key, value) = "key = value".split("=").map { it.trim() }
|
||||
val (key, value) = "key = value".splitBy("=").map { it.trim() }
|
||||
assertEquals(key, "key")
|
||||
assertEquals(value, "value")
|
||||
}
|
||||
|
||||
@@ -292,14 +292,14 @@ class StringTest {
|
||||
|
||||
|
||||
test fun split() {
|
||||
assertEquals(listOf(""), "".split(";"))
|
||||
assertEquals(listOf(""), "".splitBy(";"))
|
||||
assertEquals(listOf("test"), "test".split(*charArray()), "empty list of delimiters, none matched -> entire string returned")
|
||||
assertEquals(listOf("test"), "test".split(*array<String>()), "empty list of delimiters, none matched -> entire string returned")
|
||||
assertEquals(listOf("test"), "test".splitBy(*array<String>()), "empty list of delimiters, none matched -> entire string returned")
|
||||
|
||||
assertEquals(listOf("abc", "def", "123;456"), "abc;def,123;456".split(';', ',', limit = 3))
|
||||
assertEquals(listOf("abc", "def", "123", "456"), "abc<BR>def<br>123<bR>456".split("<BR>", ignoreCase = true))
|
||||
assertEquals(listOf("abc", "def", "123", "456"), "abc<BR>def<br>123<bR>456".splitBy("<BR>", ignoreCase = true))
|
||||
|
||||
assertEquals(listOf("abc", "def", "123", "456"), "abc=-def==123=456".split("==", "=-", "="))
|
||||
assertEquals(listOf("abc", "def", "123", "456"), "abc=-def==123=456".splitBy("==", "=-", "="))
|
||||
}
|
||||
|
||||
test fun splitToLines() {
|
||||
|
||||
Reference in New Issue
Block a user