check if string contains alphabite characters or no

PHOTO EMBED

Sat Sep 24 2022 01:49:44 GMT+0000 (UTC)

Saved by @Coder_x #kotlin

fun addStrNums( num1: String,  num2: String):String {

    var isNum1 = true
    var isNum2 = true

    isNum1 = num1.matches("-?\\d+(\\.\\d+)?".toRegex())
	isNum2 = num2.matches("-?\\d+(\\.\\d+)?".toRegex())
    
    if (isNum1 && isNum2){
        var n1 = num1.toInt()
        var n2 = num2.toInt()
        
        return "${n1+n2}"
    }
    else return "not Number"
}
content_copyCOPY