[Solved] How to Remove number from Extension with string?


You can use regex as shown or a simple LINQ query, i’d also recommend System.IO.Path:

string originalPath = "Url1234.pdf";
string dir = Path.GetDirectoryName(originalPath);              // in this case ""
string extension = Path.GetExtension(originalPath);            // .pdf
string fn = Path.GetFileNameWithoutExtension(originalPath);    // Url1234
string newFn = String.Concat(fn.Where(c => !Char.IsDigit(c))); // Url
string newPath = Path.Combine(dir, newFn + extension);         // Url.pdf

1

solved How to Remove number from Extension with string?