// 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.Text.RegularExpressions; namespace E { public class Program { private static readonly Regex retrim = new Regex(@"(^\d-)|(-\d$)", RegexOptions.Compiled); public static void Test(string s) { Console.WriteLine("{0} -> {1}", s, retrim.Replace(s, "")); } public static void Main(string[] args) { Test("1-123"); Test("223-0"); Test("4-246"); Test("289-3"); } } }