求一段字符串解析思路

try2354 2012-03-21 03:23:32
字符串的内容如下:
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...
依次循环

正则表达式应该可以实现,但对正则不熟悉,请教高手,谢谢。
...全文
63 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
try2354 2012-03-21
  • 打赏
  • 举报
回复
非常感谢2位的回复,马上结贴。

谢谢!!
传递正能量 2012-03-21
  • 打赏
  • 举报
回复
楼上的错了2个小字符

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[i].Groups[2].Value + "<br />");
Response.Write("描述:" + mc[i].Groups[3].Value + "<br />");

Response.Write("<br /><br /><br /><br /><br /><br /><br /><br /><br />");
}
传递正能量 2012-03-21
  • 打赏
  • 举报
回复
吾 比楼上的粗鲁了许多


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 />");
}
dalmeeme 2012-03-21
  • 打赏
  • 举报
回复
		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>");
}

输出:
标题: 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.

标题: 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.

62,268

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧