How to remove all letters from an alphanumeric string in Scala

1 Answer

0 votes
object Main {
    def removeLetters(input: String): String = {
        input.filterNot(ch => ch.isLetter)
    }
    def main(args: Array[String]) = {
        val input = "abc123XYZ456programming789"

        val result = removeLetters(input)

        println(result) 
    }
}


/*
run:

123456789

*/

 



answered 5 hours ago by avibootz
...