I want to check if a string with an undefined length consist of only numbers. Example:
"234324" = true
"er32" = false
"1" = true
the way I tried to solve this problem is like this:
public bool Validate(string input)
{
return (Regex.IsMatch(input, @"^\d+$")) ? true : false;
}
now im not a big hero with regular expressions, but according to everything I could find on the internet either the expression "^\+$" or "^[0-9]$" would work, but it doesnt :(
$not matching on it would be the only reason why you code does not work to my eyes.condition ? true : falseis equivalent tocondition