Generalize String extensions to take CharSequence as receiver and parameters where applicable.
This commit is contained in:
@@ -109,7 +109,7 @@ public class Regex(pattern: String, options: Set<RegexOption>) {
|
||||
* the given function [transform] that takes [MatchResult] and returns a string to be used as a
|
||||
* replacement for that match.
|
||||
*/
|
||||
public inline fun replace(input: CharSequence, transform: (MatchResult) -> String): String {
|
||||
public inline fun replace(input: CharSequence, transform: (MatchResult) -> CharSequence): String {
|
||||
var match = match(input)
|
||||
if (match == null) return input.toString()
|
||||
|
||||
|
||||
@@ -43,9 +43,7 @@ public inline fun String.matches(regex : String) : Boolean {
|
||||
return result != null && result.size() > 0
|
||||
}
|
||||
|
||||
public inline fun CharSequence.isEmpty(): Boolean = this.length() == 0
|
||||
|
||||
public fun String.isBlank(): Boolean = length() == 0 || matches("^[\\s\\xA0]+$")
|
||||
public fun CharSequence.isBlank(): Boolean = length() == 0 || (if (this is String) this else this.toString()).matches("^[\\s\\xA0]+$")
|
||||
|
||||
public fun String?.equals(anotherString: String?, ignoreCase: Boolean = false): Boolean =
|
||||
if (this == null)
|
||||
|
||||
Reference in New Issue
Block a user