I am trying to parse the following string
val s1 = """ "foo","bar", "foo,bar" """
And out put of this parsing I am hoping is...
List[String] ["foo","bar","foo,bar"] length 3
I am able to parse the following
val s2 = """ "foo","bar", 'foo,bar' """
By using the following pattern
val pattern = "(('[^']*')|([^,]+))".r
pattern.findAllMatchIn(s2).map(_.toString).toList
gives ["foo","bar", 'foo,bar'] :length 3
EDIT Currently I am able to parse: "foo,bar,foo bar" => [foo,bar,foo bar"] "foo,bar, 'foo bar' " => [foo, bar , 'foo bar'] //len 3
I want to parse these lines as well..
But I am not able to figure out the pattern for s2.. Note that I need to parse both s1 and s2 successfully
Currently I am able to parse:
"foo,bar,foo bar" => [foo,bar,foo bar"]
"foo,bar, 'foo bar' " => [foo, bar , 'foo bar'] //len 3
I want to parse these lines as well.. along with the following line:
""" foo, bar, "foo,bar" """ // gives [foo,bar,"foo,bar"] len 3