HTMLPage1.htm的代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<style type="text/css">
.aa{ width:1000px; height:100px; border:#aaa 1px solid;}
</style>
<script type="text/javascript">
{0}
{1}
</script>
</head>
<body>
<div class="aa">{2}</div>
<div>{3}</div>
<div>{0}</div>
</body>
</html>
protected void Page_Load(object sender, EventArgs e)
{
string path= Server.MapPath("~/HTMLPage1.htm");
string content= File.ReadAllText(path);
content=content.Replace("{", "{{").Replace("}", "}}");
string reg=@"{{\d}}";
MatchCollection m= Regex.Matches(content,reg);
for(int i=0;i<m.Count;i++)
{
string aa = m[i].Groups[0].Value.TrimStart('{').TrimEnd('}');
content = content.Replace(m[i].Groups[0].Value, "{" + m[i].Groups[0].Value.TrimStart('{').TrimEnd('}') + "}");
}
string str = string.Format(content, "aa", "bb", "cc", "dd");
}