I'd implement it using regex
fun String.convertPhoneNumber(): String { return this.replace("[^+\\d]".toRegex(), "") }