日期:2014-05-17  浏览次数:20781 次

C#如何将txt文件是的读到二给数据中
如下一个txt文件中,引号里面的内容读到一个二给数据中,其中红圈圈内容不要。
请问一下各位大虾和大神,该如何处理。谢谢了

c# txt 二维数据

------解决方案--------------------
用正则取吧    xxxxxx([\s\S]+)xxxx
------解决方案--------------------
每次读取一行,然后用正则查找!
------解决方案--------------------
正则学的不好!帮不了楼主了
------解决方案--------------------
用正则干吧,等个正则高手来给你匹配下!
------解决方案--------------------
每次读取一行,然后用正则查找! 
------解决方案--------------------
string tempStr = File.ReadAllText(@"C:\Users\myx\Desktop\Test.txt", Encoding.GetEncoding("GB2312"));//读取txt


                List<List<string>> _list = new List<List<string>>();
                string pattern = @"(?i)time=(['""]?)(?<Time>[^'""]*?)\1\s*?id=(['""]?)(?<Id>[^'""]*?)\2\s*?name=(['""]?)(?<Name>[^'""]*?)\3\s*?";
                pattern += @"card_src=(['""]?)(?<Card_src>[^'""]*?)\4\s*?type=(['""]?)(?<Type>[^'""]*?)\5\s*?";
                foreach (Match m in Regex.Matches(tempStr, pattern))
                {
                    List<string> _line = new List<string>();
                    _line.Add(m.Groups["Time"].Value);
                    _line.Add(m.Groups["Id"].Value);