// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Collections.Generic; using System.Text.RegularExpressions; namespace E { public class Program { public static void Main(string[] args) { List oldList = new List(); List newList = new List(); oldList.Add("this has some white space"); oldList.Add("this also has some white space"); foreach(String s in oldList) { Console.WriteLine(s); } foreach(String s in oldList) { newList.Add(Regex.Replace(s, "(?<= ) ", "")); } foreach(String s in newList) { Console.WriteLine(s); } } } }