It’s really easy to make a regular expression to get matches:
string[] input = new string[6]
{
"[email protected]", // match
"[email protected]", // match
"[email protected]", // match
"[email protected]", // not a match
"[email protected]", // not a match
"[email protected]" // not a match
};
string pattern = @"Auto_gen_\d{4}@mail.com"; //\d{4} means 4 digits
foreach (string s in input)
{
if (Regex.IsMatch(s, pattern))
{
Console.WriteLine(string.Format("Input {0} is valid",s));
}
else {
Console.WriteLine (string.Format("Input {0} is not valid",s));
}
}
Console.ReadKey();
solved Check string format consist of specific words then number then specific words in c# [closed]