按照你的要求取出IP地址和端口号,并保存为一个数组,需要用正则表达式匹配IP地址和端口号
具体程序如下
using System;
using System.Text.RegularExpressions;
namespace MatchSocketApplication{
class MatchSocketClass{
static void Main(string[] args){
string []xx=new string[100];
int count=0;
string s="enable: trueEddy: /47.102.102.240:45808yongsheng: /182.244.227.3:38215loulan: /222.137.211.109:52149FYDmalingshu: /47.102.102.240:45862_Depth: /58.18.66.232:62040";
MatchCollection mc =Regex.Matches(s, @"\d+\.\d+\.\d+\.\d+:\d+");
foreach (Match m in mc){
xx[count]=m.Groups[0].Value;
count++;
}
for(int i=0;i
Console.WriteLine(xx[i]);
}
Console.ReadKey();
}
}
}