I am trying to use regular expressions to do some work on strings but I am having some difficulty. My goal is to replace numbers in a string with a character, specifically if there is a group of numbers in the string I want to replace the entire group of numbers with a *. If there is just a single digit I want to replace that with a ?.
For example, if I had the string "test12345.txt" I would like to turn that to "test*.txt", but if I have "test1.txt" I would like to turn that to just "test?.txt".
I tried
Regex r = new Regex(@"\d+", RegexOptions.None);
returnString = r.Replace(returnString, "*");
But this replaces replaces even a single digit on its own with a *