https://kotlinlang.org logo
l

luke

01/22/2020, 4:07 AM
Anyone any good with Regex? Struggling with this.
1914   1    5.9     0.9    ---     48.3    ---
What I have so far:
([\d]+)\.*([\s]+)
I just want to extract all the non-whitespace values into an Array.
r

Ruckus

01/22/2020, 4:45 AM
Why not just use split?
l

luke

01/22/2020, 5:38 AM
because there's an unknown number of spaces between each value, so using
.split(" ")
doesnt help.
r

Ruckus

01/22/2020, 5:49 AM
I could be wrong, but I believe if you don't pass in a delimiter (i.e. just
.split()
), it will do what you want. If not, you could just use
\s+
as your delimiter.
l

luke

01/22/2020, 5:51 AM
image.png
You're right, it's just not behaving as I thought it would.
OK, the key is using the
Regex
class.
r

Ruckus

01/22/2020, 6:31 AM
Ah, indeed. Sorry about that. I'm glad you figured it out.
2 Views