- UID
- 1023
- UCC
-
- 声望
-
- 好评
-
- 贡献
-
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2009-6-8 17:49:14
|
显示全部楼层
本帖最后由 Euyis 于 2009-6-8 17:51 编辑
暂存...- public void Extract(string SectionName)
- {
- Match m;
- string pattern = "[[]" + SectionName + "[]]";
- int matchShift = SectionName.Length + 2 + 2;
- int sliceBegin = 0, sliceEnd = 0;
- m = Regex.Match(str, pattern);
- while (m.Success)
- {
- sliceBegin = m.Groups[0].Index + matchShift;
- m = m.NextMatch();
- if (m.Success)
- {
- sliceEnd = m.Groups[0].Index;
- MessageBox.Show(str.Substring(sliceBegin, sliceEnd - sliceBegin));
- }
- else {
- sliceBegin = sliceEnd + matchShift;
- MessageBox.Show(str.Substring(sliceBegin));
- }
- }
- }
复制代码 |
|