Kurik9797
Kurik9797

Reputation: 37

Delete all letters from String

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

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

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

Related Questions