I would like to add a certain number of leading zeroes to a number in a string. For example:
Input: \"page 1\", Output: \"page 001\" Input: \"page 12\", Ouput: \"pa
string sInput = "page 1 followed by page 12 and finally page 123"; string sOutput = Regex.Replace(sInput, "[0-9]{1,2}", m => int.Parse(m.Value).ToString("000"));