try something likeusing System.Text.RegularExpressions;String s = "....";Regex re = new Regex(@"person\s+(?<person>.*?)\s+(phone\s+(?<phone>.*?)\s+)?(fax\s+(?<fax>.*?)\s+)?", RegexOptions.IgnoreCase| RegexOptions.Singleline);MatchCollection mc = re.Matches(s);
Console.WriteLine(mc.Count);
for (int i=0; i < mc.Count; i++)
{
System.Console.WriteLine("person:" + mc[i].Groups["person"]);
System.Console.WriteLine("phone:" + mc[i].Groups["phone"]);
System.Console.WriteLine("fax:" + mc[i].Groups["fax"]);
}
Console.WriteLine(mc.Count);
for (int i=0; i < mc.Count; i++)
{
System.Console.WriteLine("person:" + mc[i].Groups["person"]);
System.Console.WriteLine("phone:" + mc[i].Groups["phone"]);
System.Console.WriteLine("fax:" + mc[i].Groups["fax"]);
}
解决方案 »
- 委托跟事件的问题,高手们求指教..
- C#实现保存于显示快捷键列表
- excel导入时候excel文件一定要放到服务器端么?
- TREEVIEW的问题
- c# windows form应用程序 如何发布!!
- 请教关于编码问题
- 请教WPF数据绑定的问题
- .NET有像非.NET平台COMAdmin那样的.NET的类库吗?
- 关于C#的单元测试————讨论
- 使用了盗版.net2003的C#开发了Web,其中用到crystalreport,,这样存在crystalreport的版权问题吗?
- 请微软专家或版主解答:实现动态载入模块后,如何实现以MDI子窗体方式调用载入模块的窗体?
- 急啊!!!如何设置VS IDE使其能编译unsafe代码?
btw, i have a empty post for u. you can just give a simple reply. i then give you the 100 points i promised.