Wednesday, March 13, 2013

Regular expression to verify that a string contains between 1 and 40

Regex r = new Regex(@"^[\w]{1,40}$");
       
if (r.Match(strName).Success)
{
    // Valid
}
else
{
    // Not Valid
}

No comments:

Post a Comment