C# Regex Validation Rule using Regex.Match()

The regex for 4 alphanumeric characters follows by 6 to 7 decimal digits is:

var regex = @"^\w{4}\d{6,7}$";

See: Regular Expression Language – Quick Reference


The Regex.Match Method returns a Match object. The Success Property indicates whether the match is successful or not.

var match = Regex.Match(input, regex, RegexOptions.IgnoreCase);

if (!match.Success)
{
    // does not match
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)