public record LData(string L, string[] Value);
public static void Parse1() {
string text = "5.0,15,4.0,25,3.0,10:L10;5.0,18,4.0,42,3.0,12:L20";
List<LData> datas = new();
StringBuilder sb = new();
List<string> list = new();
bool readL = false;
void AddDatas()
{
readL = false;
datas.Add(new(sb.ToString(), list.ToArray()));
sb.Clear();
list.Clear();
}
foreach (var item in text)
{
if (readL)
{
if (item != ';')
sb.Append(item);
else
AddDatas();
}
else
{
switch (item)
{
case ',':
list.Add(sb.ToString());
sb.Clear();
break;
case ':':
sb.Append(item);
list.Add(sb.ToString());
sb.Clear();
readL = true;
break;
default:
sb.Append(item);
break;
}
}
}
AddDatas();
}
or
public static void Parse2() {
string text = "5.0,15,4.0,25,3.0,10:L10;5.0,18,4.0,42,3.0,12:L20";
List<LData> datas2 = new();
string[] records = text.Split(';');
//5.0,15,4.0,25,3.0,10:L10
//5.0,18,4.0,42,3.0,12:L20
foreach (var item in records)
{
var d = item.Split(':');
//0 = 5.0,15,4.0,25,3.0,10
//1 = L10
datas2.Add(new(d[1], d[0].Split(",")));
}
}