Skip to content

Commit

Permalink
Add support for multi-space delimiter
Browse files Browse the repository at this point in the history
  • Loading branch information
Bokonon79 committed Jan 21, 2019
1 parent ae7a4fd commit f32163b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion CANLib/DataWithColumns.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public enum SeparatorType
{
Comma,
Semicolon,
Space
Space,
MultiSpace
}
public SeparatorType Separator
{
Expand Down Expand Up @@ -144,6 +145,9 @@ List<string> ParseRow(string line)
case SeparatorType.Space:
regexSeparatedValues = regexSeparatedValuesBySpace;
break;
case SeparatorType.MultiSpace:
regexSeparatedValues = regexSeparatedValuesByMultiSpace;
break;
}

Match matchSeparatedValues = regexSeparatedValues.Match(line);
Expand Down Expand Up @@ -246,6 +250,10 @@ protected void ReadBlankLine(StreamReader streamReader)
@"^(?:(?:^| )(?:()|([^""][^ ]*)|""((?:[^""]|"""")*)""))+$",
RegexOptions.Compiled | RegexOptions.CultureInvariant);

static readonly Regex regexSeparatedValuesByMultiSpace = new Regex(
@"^(?:(?:^| +)(?:()|([^""][^ ]*)|""((?:[^""]|"""")*)""))+$",
RegexOptions.Compiled | RegexOptions.CultureInvariant);

void ReadColumnHeader(StreamReader streamReader)
{
string line = streamReader.ReadLine();
Expand Down

0 comments on commit f32163b

Please sign in to comment.