正则表达式
1,字符串的提取
a.先创建好符合规则的正则表达式
b.将部分用()包含
string str = "192.168.10.5[port=21,type=ftp]";
Match macth = Regex.Match(str, @"^(.+)[[].+=(\d{2}),.+=(.+)[]]$");
if (macth.Success)
{
Console.WriteLine(macth.Groups[1]);
Console.WriteLine(macth.Groups[2]);
Console.WriteLine(macth.Groups[2]);
}
邮箱:[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z].{2,4}

浙公网安备 33010602011771号