[Solved] Scala: extract the word before a specific character [closed]


May be something like this will do

Steps:-

1.Split the string by space delimiter.

2.Map through the Seq of strings created in the first step and split by . delimiter.

val s = "abc.def ghi.jkl mno.pqr"

val strS = s.split(" ").toSeq

val firstStrS = strS.map { s=>
  val t = s.split('.').toSeq
  t.head
}.mkString(" ")

Hope this helps!

0

solved Scala: extract the word before a specific character [closed]