using System.Text.RegularExpressions;
public static void Main()
tableData += "| header1 | header2 | header3 |\r\n";
tableData += "| --- | --- | --- |\r\n";
tableData += "| data1 | data2 | data3 |\r\n";
tableData += "| data4 | data5 | data6 |\r\n";
string[] tableRows = tableData.Trim().Split(new[]{"\r\n", "\r", "\n"}, StringSplitOptions.None);
Console.WriteLine("\"" + tableData + "\"");
foreach (var tableRow in tableRows)
string tableRowRaw = tableRow;
string tableRowFormatted = Regex.Replace(tableRowRaw, "^\\||\\|$", string.Empty);
Console.WriteLine("Row[" + rowCount + "]: " + tableRowFormatted);
string[] rowCells = tableRowFormatted.Split(new[]{"|"}, StringSplitOptions.None);
foreach (var cellData in rowCells)
Console.WriteLine("Cell[" + cellCount + "]: " + cellData.Trim());