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
@@ -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