Check Digits using regular expression
Format:digits only
The below is the regular expression which we can use in .NET code behind
using System.Text.RegularExpression;
protected void Page_Load(object sender, EventArgs e)
{
bool sDigits=false;
sDigits=Regex.IsMatch(SIMNumber.Text.Trim(), @"^\d+$");
if(sDigits == true)
{
label1.Text="It is a number";
}
else
{
label1.Text="Its not number";
}
Format:24 Digits with 21st digits as numeric/alphanumeric[(12345678912345678901A345) or 12345678912345678901a345 or 123456789123456789018345]
using System.Text.RegularExpression;
protected void Page_Load(object sender, EventArgs e)
{
bool sDigits=false;
sDigits=Regex.IsMatch(SIMNumber.Text.Trim(), @"^\d{20}[0-9a-zA-Z]{1}\d{3}$");
if(sDigits == true)
{
label1.Text="It is correct Format";
}
else
{
label1.Text="Its not a correct Format";
}