2

Scenario same

First of all I don't know anything about RegularExpressions.

I am trying to split a string separated with comma(,). In my scenario there is a string which is a single record having double quotes in it("smilu,varghese") I found the answer in the above link. But when I try to do the RegularExpression it is giving me a wrong array.

Text to split

One,two,Three,"Four,Five",six

I need the record to be split like

One
two
three
Four,Five
six

The regular expression I am using

string[] lineArray = Regex.Split(line, @"(?<=[^""]),(?=[^""])", RegexOptions.None);

I know the above code is wrong and it is giving me a random split on the string. Can anyone tell me how to write this regular expression for keeping the string between quotes(") in a single string?

Community
  • 1
  • 1
smilu
  • 859
  • 7
  • 30
  • 53

0 Answers0