我需要打印从001到100的所有电子邮件。例如,[email protected]直到[email protected]我正在尝试使用正则表达式,我将需要递增1的数字分开,但是我不知道如何构造for循环。
string email = "[email protected]";
Regex regex = new Regex(@"\d+");
var parts = email.Split('@');
string prefix = Regex.Replace(email, @"\d+", "");
您实际上可以在不使用正则表达式的情况下进行操作,将数字从1
循环到100
,然后使用string interpolation将数字添加到电子邮件模板中>]
for (int i = 1; i <= 100; i++)
{
var email = $"test+{i:000}@gmail.com";
Console.WriteLine(email);
}