fun main() { print(countWords("Return number of words in String")) } fun countWords( txt: String):Int { var totalWords = txt.trim().split("\\s+".toRegex()).size return totalWords }
fun main() { print(countWords("Return number of words in String")) } fun countWords( txt: String):Int { var totalWords = txt.trim().split("\\s+".toRegex()).size return totalWords }