// Collection of code snippets by Arne Vajhøj
// posted to eksperten.dk, usenet and other places (2002-now)
using System;
using System.Text;
class MainClass
{
public static string makeids(string tbl)
{
StringBuilder sb = new StringBuilder();
int oldix = 0;
int ix = 0;
int n = 0;
while((ix = tbl.IndexOf("
", oldix)) >= 0)
{
n++;
sb.Append(tbl.Substring(oldix, ix - oldix));
sb.Append(" | ");
oldix = ix + " | ".Length;
}
sb.Append(tbl.Substring(oldix));
return sb.ToString();
}
public static void Main(string[] args)
{
Console.WriteLine(makeids(" | aaa | "));
Console.WriteLine(makeids("aaabbb | cccddd | eee"));
Console.WriteLine(makeids("aaa | bbb | "));
Console.WriteLine(makeids("aaa"));
Console.WriteLine(makeids(""));
}
}