日期:2014-05-18  浏览次数:20380 次

求一段字符串解析思路
字符串的内容如下:
Session 1: Get started with the right template (Tuesday, January 10)
See how to get started in Microsoft Visio 2010 with the right template. This video introduces the eight categories of templates available in Visio 2010: business, engineering, flowchart (including Business Process Modeling Notation [BPMN] and SharePoint workflow templates in Visio Premium 2010), general, maps and floor plans, network, schedule, and software and database. It also shows how easy it is to create drawings by starting with sample diagrams. 
Watch Session 1 video
Download sample diagrams used in the Session: HVAC Plan, Timeline, and Templates by Edition. 


Session 2: Find and navigate key features (Tuesday, January 17)
Learn about the new user interface in Microsoft Visio 2010. This video introduces the ribbon user interface, which is adopted from Microsoft Office 2010. It covers the main tabs—Home, Insert, Design, Data (in Visio Professional and Visio Premium), Process (in Visio Premium), Review, View, and Developer (for advanced users)—as well as contextual and add-in tabs that appear when relevant. It also looks at the Backstage view, where you can find new templates, recent files, and sample diagrams. 
Watch Session 2 video
Download sample diagram used in the Session: Simple Flowchart.

如何解析才能得到它的一条条的标题,时间以及描述?
最终想得到的内容是:
标题:Session 1: Get started with the right template
时间:Tuesday, January 10
描述:See how to get started in Microsoft Visio...
依次循环

正则表达式应该可以实现,但对正则不熟悉,请教高手,谢谢。

------解决方案--------------------
C# code
        string s = File.ReadAllText(Server.MapPath("~/test.txt"));
        MatchCollection matches = Regex.Matches(s, @"(?s)Session\s*\d+:([^()]+)\((.+?)\)\s+(.+?)(?=\s+Session\s*\d+:|$)");
        foreach (Match match in matches)
        {
            Response.Write("标题:" + match.Groups[1].Value + "<br/>");
            Response.Write("时间:" + match.Groups[2].Value + "<br/>");
            Response.Write("描述:" + match.Groups[3].Value + "<br/></br>");
        }

------解决方案--------------------
吾 比楼上的粗鲁了许多


string str = this.TextBox1.Text;


Regex r = new Regex(@"(.+)\((.+)\)(.+)", RegexOptions.Multiline);

MatchCollection mc = r.Matches(str);

for (int i = 0; i < mc.Count; i++)
{


Response.Write("标题:" + mc[i].Groups[1].Value + "<br />");
Response.Write("时间:" + mc[2].Groups[2].Value + "<br />");
Response.Write("描述:" + mc[3].Groups[3].Value + "<br />");

Response.Write("<br /><br /><br /><br /><br /><br /><br /><br /><br />");
}