Regex that accepts only numbers (0-9) and NO characters
Your regex ^[0-9] matches anything beginning with a digit, including strings like “1A”. To avoid a partial match, append a $ to the end: This accepts any number of digits, including none. To accept one or more digits, change the * to +. To accept exactly one digit, just remove the *. UPDATE: You mixed up the arguments to IsMatch. The pattern should be the second argument, … Read more