Skip to content

How to trim excess linefeeds from my measures #588

Discussion options

You must be logged in to vote

Hi @edhans,
you can use TrimStart to remove all leading blank lines. In the following example I've also included .Replace("\r\n", "\n") just to be sure that the line ending characters are normalised in the formatted string.

foreach (var m in Model.AllMeasures) 
{ 
    m.Expression = '\n' + m.Expression.Replace("\r\n", "\n").TrimStart('\n'); 
}

I am not sure I understand your second question. This code seems to work correctly without any conversion errors

foreach (var m in Model.AllMeasures) 
{ 
    m.Description = string.Join("\n", m.Expression.Split('\n').Take(16));
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@edhans
Comment options

Answer selected by edhans
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content: script assistance Help on C# scripting
2 participants