def move_first_word_to_end_of_string(s: String): String = {
val parts = s.trim.split("\\s+").toList
parts match {
case Nil | _ :: Nil => s.trim
case first :: rest => (rest :+ first).mkString(" ")
}
}
val s = "Would you like to know more? (Explore and learn)"
val result = move_first_word_to_end_of_string(s)
println(result)
/*
run:
you like to know more? (Explore and learn) Would
*/