Ink
05/05/2022, 4:21 PM[5-XR6Bwlq, 2-Hada32U1D, 7-aaGE7Ve84]
I want to get every single number before -
and create list of Int with that values.
How I can achive that?Klitos Kyriacou
05/05/2022, 4:40 PMstr.substring(1, str.length - 1).split(", ").map { it.substringBefore("-").toInt() }
nkiesel
05/05/2022, 5:35 PMRegex("""(\d+)-\w+""")
.findAll(input)
.map { it.groupValues[1].toInt() }
.toList()
might workInk
05/05/2022, 5:42 PMNumberFormatException: Infinite or NaN
Ink
05/05/2022, 5:43 PMnkiesel
05/05/2022, 5:44 PMnkiesel
05/05/2022, 5:48 PM[1-ok, b-bad]
by using
Regex("""(\d+)-[\w-]+""")
.findAll(input1)
.mapNotNull { it.groupValues[1].toIntOrNull() }
.toList()
Ink
05/05/2022, 5:53 PMnull
.toString()