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#.
THANKS
ReplyDeleteTanks you,
ReplyDeleteyour code can help me .....
thanks alot...!!!
ReplyDeleteGracias .....
ReplyDeleteThanks....
ReplyDeleteVery Nice code
This will do the same thing and requires less logic:
ReplyDelete^[0-9]+$
Thanks, it helped me a lot.
ReplyDelete