Reputation: 37
How can i delete all letters from String? I've got given String:
val stringData ="ABC123.456"
Output value:
val stringData ="123.456"
Upvotes: 1
Views: 83
Reputation: 521389
We can try regex replacement here:
val regex = """[A-Za-z]+""".toRegex()
val stringData = "ABC123.456"
val output = regex.replace(stringData, "")
println(output) // 123.456
Upvotes: 3