singleOrNull

Returns single character, or null if the char sequence is empty or has more than one character.

Since Kotlin

1.0

inline fun CharSequence.singleOrNull(predicate: (Char) -> Boolean): Char?(source)

Returns the single character matching the given predicate, or null if character was not found or more than one character was found.

Since Kotlin

1.0