Vivek Modi
01/24/2022, 4:11 PMval string = "Hey 123"
or val string = "Hey How are you 123"
and output string = 123
Javier
01/24/2022, 4:17 PMstring.replace(..., "")
Javier
01/24/2022, 4:18 PMsubstringAfter/Before
too but passing a regex to the replace is simpler (or easier to read)Vampire
01/24/2022, 4:25 PMstring.replace("""\D++""".toRegex(), "")
Vivek Modi
01/24/2022, 4:41 PMPaul Woitaschek
01/24/2022, 6:00 PMVivek Modi
01/24/2022, 6:05 PMVampire
01/24/2022, 6:06 PMstring.filter { it.isDigit() }
actually, but yeahVivek Modi
01/24/2022, 6:08 PMColton Idle
01/25/2022, 5:35 AMPaul Woitaschek
01/25/2022, 9:23 AMPaul Woitaschek
01/25/2022, 9:23 AMJavier
01/25/2022, 2:19 PMstring = "hey 123"
, if it has only digit, then the string.filter(String::isDigit)
is more readable