Processing Ajax...

Title

Message

Confirm

Confirm

Confirm

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure you want to delete this item?

Trim All Lines

Description
Takes a list of values and trims each line so that there is no white space remaining on either side of each line. The line endings still remain.
Language
C#.net
Minimum Version
Created By
wooster11
Contributors
-
Date Created
Aug 19, 2014
Date Last Modified
Aug 19, 2014

Macro Code

using System;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        System.IO.StringReader sr = new System.IO.StringReader(text);
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        string line;
        int count = 0;
        int failSafe = 100000; //Set Failsafe to 100,000 so that we'll break after that many tries

        line = sr.ReadLine();
        while (line != null)
        {
            sb.AppendLine(line.Trim());
            line = sr.ReadLine();
            count += 1; //increment count and check if we're in an infinite loop
            if (count == failSafe)
                return "Failed.\nFail Safe At: " + failSafe.ToString() + "\nCopy Fewer Lines";
        }
        return sb.ToString();
    }
}