using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text.RegularExpressions; public class Test { public static void Main() { var strings = new List { "msl_0123456789_otherstuff.csv", "msl_test.xml", "anythingShort.w1" }; foreach (var s in strings) { Console.WriteLine("{0} => {1}", s, new string(Regex.Replace(s, @"^msl_|\.\w{1,3}$","").Take(10).ToArray())); } } }