以下是代码片段:
StringWriter textBuffer = new StringWriter();
Match match= Regex.Match(HTMLStr,@"",RegexOptions.IgnoreCase | RegexOptions.Compiled);
if(match==null)
{
Response.Write(HTMLStr);
return;
}
string codeType = match.Groups["codeType"].Value;
string content = match.Groups["codeContent"].Value;
if(codeType==String.Empty || content==String.Empty)
{
Response.Write(HTMLStr);
return;
}
// MessageBox.Show(codeType);
// MessageBox.Show(content);
string[] sr = content.Split(Convert.ToChar("\n"));
if(codeType=="C#")
{
textBuffer.Write("
1<csharp>\r\n");
2foreach(string sourceLine in sr)
3{
4textBuffer.Write(FixCSLine(sourceLine)) ;
5textBuffer.Write("\r\n");
6}
7textBuffer.Write("</csharp>
");
}
else if(codeType=="JScript.Net")
{
textBuffer.Write("
1<jscript.net>\r\n");
2foreach(string sourceLine in sr)
3{
4textBuffer.Write(FixJSLine(sourceLine)) ;
5textBuffer.Write("\r\n");
6}
7textBuffer.Write("</jscript.net>
");
}
else if(codeType=="VB")
{
textBuffer.Write("
1<vb>\r\n");
2foreach(string sourceLine in sr)
3{
4textBuffer.Write(FixVBLine(sourceLine)) ;
5textBuffer.Write("\r\n");
6}
7textBuffer.Write("</vb>
");
}