How to split a string to a 2D array

Domain dont_email at empty.com
Sat Feb 24 07:51:27 UTC 2018


I want to convert a string like " a,b<br/>1, 2<br/>3<br/> " to a 
2D array like:
[["a", "b"],
  ["1", "2"],
  ["3", "" ]]


auto html = " a,b<br/>1, 2<br/>3<br/> ";
auto rows = html.strip.chomp("<br/>").split("<br/>");
string[][] data;
rows.each!(a => data ~= a.split(","));
string[][] result = data.map!(a => a.padRight("", 
data[0].length).map!(b => b.strip)).array;

but the result is not a string[][]:

Error: cannot implicitly convert expression `array(map(data))` of 
type `MapResult!(__lambda2, Result)[]` to `string[][]`



More information about the Digitalmars-d-learn mailing list