c# regex only numbers in string code example Example: regex for numbers Regex regex = new Regex(@"^\d$");