static List<int> ParseSectionsForNameShortening(string name)
{
//split string p_a.b.c_d.e.f_s into sections splitted by _
// [pos of section start, [removable subsection, ...], removable subSections count]
var parsed = new List<int> { 0 }; // 0,0,|1,2,2,2|7,2,2,2,|13,0
var sectionCount = 0;
var removableSectionStart = 0;
for (int i = 0; i < name.Length; i++)
{
if (name[i] == '_')
{
parsed.Add(sectionCount);
parsed.Add(i);
sectionCount = 0;
removableSectionStart = i + 1;
}
else if (name[i] == '.')
{
parsed.Add(i - removableSectionStart + 1);
sectionCount++;
removableSectionStart = i + 1;
}
}
parsed.Add(sectionCount);
return parsed;
}