结果:
0 0
0 0
-6361 0
-6384 -6672
0 0
0 -6793 ...
代码:
string regex = @"X:(.*?)\sY:(.*?)";
if (File.Exists("minelist.log"))
File.Delete("minelist.log");
File.Copy(war3path + "\\minelist.log", "minelist.log");
string[] crdlist = File.ReadAllLines("minelist.log");
for (int i = 0; i < crdlist.Length;i++)
{
Match COORM = Regex.Match(crdlist[i], regex);
if (COORM.Success)
{
float x = 0.0f, y = 0.0f;
float.TryParse(COORM.Groups[1].Value, out x);
float.TryParse(COORM.Groups[2].Value, out y);
MessageBox.Show(x.ToString(), y.ToString());
}
}
if (File.Exists("minelist.log"))
File.Delete("minelist.log");
结果,只解析了某些值。其他 = 0。
结果:0 0 0 0 6361 0 -6384 6672 0 0 0 -6793 ...