Revert back 2nd stage of split semantics change and restore deprecated String.split(String).

This commit is contained in:
Ilya Gorbunov
2015-05-21 05:00:48 +03:00
parent b1f1360081
commit 6516c74a1a
4 changed files with 21 additions and 11 deletions
@@ -922,10 +922,6 @@ public fun String.splitToSequence(vararg delimiters: String, ignoreCase: Boolean
* the beginning to the end of this string, and matches at each position the first element in [delimiters]
* that is equal to a delimiter in this instance at that position.
*/
public fun String.split(vararg delimiters: String, ignoreCase: Boolean = false, limit: Int = 0): List<String> =
splitToSequence(*delimiters, ignoreCase = ignoreCase, limit = limit).toList()
deprecated("Use split(delimiters) instead.")
public fun String.splitBy(vararg delimiters: String, ignoreCase: Boolean = false, limit: Int = 0): List<String> =
splitToSequence(*delimiters, ignoreCase = ignoreCase, limit = limit).toList()
@@ -127,6 +127,12 @@ public fun String.split(regex: Pattern, limit: Int = 0): List<String>
require(limit >= 0, { "Limit must be non-negative, but was $limit" } )
return regex.split(this, if (limit == 0) -1 else limit).asList()
}
/**
* Splits this string around matches of the given regular expression.
*/
deprecated("Convert an argument to regex with toRegex or use splitBy instead.")
public fun String.split(regex: String): Array<String> = split(regex.toRegex()).toTypedArray()
/**
* Returns a substring of this string starting with the specified index.