I have a file as below,
AB*xyz*1234~
CD*mny*769~
MN*bvd*2345~
AB*zar*987~
here i would like to split the data using(*) and line always ends with ~.
code.
val bufferedSource = Source.fromFile(sample.txt)
var array = Array[String]()
for (line <- bufferedSource.getLines()) {
array = line.split("\\~")
val splittedRow=array.split("\\*")
}
I want output as below which should be first words from all lined,
Array(AB,CD,MN,AB).