Regex based string maniuplation

Oh, the joys of Regex! I was faced with a simple issue which involved manipulating a string of the form “Address1, Address2, Street, City, PostCode” so that it can be split into a multiline. The bug was strangely displaying the “Address 2” data twice in the multiline array. Initially the LINQ lambda query was being mapped into an array by the ToArray() method and then iterating over the array to display each line of text within an asp literal control:

string[] addressArray = l_event.Location.Split(',').Where(s => !s.Trim().Equals(string.Empty)).ToArray();
foreach (string line in addressArray)
     litLocation.Text += line;
     litLocation.Text += " ";

I had almost given up hope fixing the above issue when I decided to try a regex based solution which magically solved this:

litLocation.Text = Regex.Replace(l_event.Location.Trim(','), @"(\s*,\s*)", " ").Trim(',');