preg_match numberic no more than x digits code example Example: regex for numbers Regex regex = new Regex(@"^\d$");