In Kotlin, I need to split a line by white spaces. I tried here using what I think is a space and a tab. Also in case there are multiple delimiters, I used a +. I try to grab the 3rd thing in that delimited string below:
val lines = File(MyFilePath).readLines()
val two = lines[7].trim().split("\\\s+","\\\t+")[2]
Maybe try like this:
val list: List<String> = lines[7].trim().split("\\s+".toRegex())
val two = list[1]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With