toUIntOrNull

Parses the string as an UInt number and returns the result or null if the string is not a valid representation of a number.

fun String.toUIntOrNull(): UInt?(source)
fun main() {
    val valid = "42".toUIntOrNull()
    val invalid = "not_a_number".toUIntOrNull()

    println(valid)   // 42
    println(invalid) // null
}

Source