regular expressions are very easy to use to validate the input value.
The sample function below show how to check if the input is number or not, code is in C#.
IsItNumber("2"); will return true;
using System.Text.RegularExpressions;
public static bool IsItNumber(string inputvalue)
{
Regex isnumber = new Regex("[^0-9]");
return !isnumber.IsMatch(inputvalue);
}
IsItNumber("A"); will return false;
Is number validation with regular expression in C#.
7 comments:
THANKS
Tanks you,
your code can help me .....
thanks alot...!!!
Gracias .....
Thanks....
Very Nice code
This will do the same thing and requires less logic:
^[0-9]+$
Thanks, it helped me a lot.
Post a Comment