Copy Code code as follows:
Namespace Webcode
{
public partial class _default:system.web.ui.page
{
protected void Page_Load (object sender, EventArgs e)
{
String str = "This is a test file <{config name=\" pagetitle1\ "}>, a label parsing <{config name=\" pagetitle2\ "count=\" 2\ "}> process ";
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);
}
}
}
Page.Form.Controls.Add
Adds a control to the end of the form node in the page.
Using System.Text.RegularExpressions;
class to use with regular expressions