日期:2014-05-17 浏览次数:20713 次
string tempStr = File.ReadAllText(@"C:\Users\myx\Desktop\Test.txt", Encoding.GetEncoding("GB2312"));//读取txt
string split_char = ",";
string pattern = string.Format(@"(?i)(?<=^
------解决方案--------------------
{0})\d+?(?={0}
------解决方案--------------------
$)", split_char);
int[] data = Regex.Matches(tempStr, pattern).OfType<Match>().Select(a=>int.Parse(a.Value)).Distinct().ToArray();//去除重复
string[] StrArray = System.IO.File.ReadAllText("D:\\test.txt").Split(',');
int[] intArray = new int[StrArray.Length];
for (int i = 0; i < StrArray.Length; i++)
{
intArray[i] = int.Parse(StrArray[i]);
}
\d+(?=\D)