I have an Array like this.
scala> var x=Array("a","x,y","b")
x: Array[String] = Array(a, x,y, b)
How do I change the separator comma
in array to a :
. And finally convert it to string like this.
String = "a:x,y:b"
My aim is to change the comma(separators only) to other separator(say,:
), so that i can ignore the comma inside second element i.e, x,y
. and later split the string using :
as a delimiter
Your question is unclear, but I'll take a shot.
To go from:
to
You can use
mkString
: