以下是代码片段:
StringWriter textBuffer = new StringWriter();
匹配 match= Regex.Match(HTMLStr,@"",RegexOptions.IgnoreCase | RegexOptions.Compiled);
如果(匹配==空)
{
响应.Write(HTMLStr);
返回;
}
string codeType = match.Groups["codeType"].Value;
字符串内容 = match.Groups["codeContent"].Value;
if(codeType==String.Empty || content==String.Empty)
{
响应.Write(HTMLStr);
返回;
}
// MessageBox.Show(codeType);
// MessageBox.Show(内容);
string[] sr = content.Split(Convert.ToChar("n"));
if(codeType=="C#")
{
textBuffer.Write("<Csharp>rn");
foreach(sr中的字符串sourceLine)
{
textBuffer.Write(FixCSLine(sourceLine)) ;
textBuffer.Write("rn");
}
textBuffer.Write("</Csharp>");
}
else if(codeType=="JScript.Net")
{
textBuffer.Write("<JScript.Net>rn");
foreach(sr中的字符串sourceLine)
{
textBuffer.Write(FixJSLine(sourceLine)) ;
textBuffer.Write("rn");
}
textBuffer.Write("</JScript.Net>");
}
else if(codeType=="VB")
{
textBuffer.Write("<VB>rn");
foreach(sr中的字符串sourceLine)
{
textBuffer.Write(FixVBLine(sourceLine)) ;
textBuffer.Write("rn");
}
textBuffer.Write("</VB>");
}