复制代码 代码如下:
namespace WebCode
{
public partial class _default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
String str = "这是一个测试文件<{config name=/"pagetitle1/"}>,一个标签的解析<{config name=/"pagetitle2/" count=/"2/"}>过程";
Label mylabel = new Label();
mylabel.ID = "display";
mylabel.Text = this.myReplace(str);
Page.Form.Controls.Add(mylabel);
}
protected String myReplace(String str)
{
String pattern = @"/</{(.*?)/}/>";
Regex p = new Regex(pattern, RegexOptions.IgnoreCase);
MatchCollection m = p.Matches(str);
String matchs = "";
for (int i = 0; i < m.Count; i++)
{
matchs += "," + m[i];
}
return matchs.Substring(1);
}
}
}
新闻热点
疑难解答
图片精选