引入命名空间:using System.Text.RegularExpressions;
private void Page_Load(object sender, System.EventArgs e)
{
string str = LoadFile("bookmark.htm");
MatchCollection category = Regex.Matches(str, "(.+?)
", RegexOptions.IgnoreCase | RegexOptions.Multiline );
foreach(Match m in category)
{
this.Label1.Text+=m.Groups[0].Value;//显示分类
}
MatchCollection link=Regex.Matches(str,"(.+?)", RegexOptions.IgnoreCase | RegexOptions.Multiline );
foreach(Match n in link)
{
this.Label2.Text+=n.Groups[0].Value;//显示列表
}
}
private string LoadFile(string file)
{
StringWriter sw = new StringWriter ();
Server.Execute (file, sw);
string content = sw.ToString ();
return content;
}
本文作者:佚名 来源:http://www.cnblogs.com/idotnet8/
CIO之家 www.ciozj.com 微信公众号:imciow