0

I have a CSV file that contains this line :

val s = "\"a,b,c,d\",2,3,4"    // it also could have been "a,b,d",2,3,4 or "a,,d",2,3,4 ...
val regex = new Regex(
    "\"([^,]+)(,+([^,]*))+\"",
    "begin",
    "test", "end")
val line = regex.replaceAllIn(s, m => m.group("begin") + "#" + m.group("end"))

The result is : a#d, 2, 3, 4

But I would like this :a#b#c#d, 2, 3, 4

Is there a way to get all the values that the regular expression detect?

GermainGum
  • 1,349
  • 3
  • 15
  • 40

0 Answers0