From f32163bdbc5a4eeb79bd9011f19ad692fcf6d746 Mon Sep 17 00:00:00 2001 From: Bokonon79 Date: Mon, 21 Jan 2019 01:56:47 -0500 Subject: [PATCH] Add support for multi-space delimiter --- CANLib/DataWithColumns.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CANLib/DataWithColumns.cs b/CANLib/DataWithColumns.cs index 7199379..c334534 100644 --- a/CANLib/DataWithColumns.cs +++ b/CANLib/DataWithColumns.cs @@ -60,7 +60,8 @@ public enum SeparatorType { Comma, Semicolon, - Space + Space, + MultiSpace } public SeparatorType Separator { @@ -144,6 +145,9 @@ List ParseRow(string line) case SeparatorType.Space: regexSeparatedValues = regexSeparatedValuesBySpace; break; + case SeparatorType.MultiSpace: + regexSeparatedValues = regexSeparatedValuesByMultiSpace; + break; } Match matchSeparatedValues = regexSeparatedValues.Match(line); @@ -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();