public static string ChangeReviewConten(string content)
{
string str = "";
Regex reg = new Regex(@"/[(em/d*?)/]");//[em303]
//img 替换
string img="<img src='images/review/{0}.gif'>";
str = reg.Replace(content, string.Format(img, "$1"));
str=Regex.Replace(str, @"/[u/](.*?)/[/u/]","<u>$1</u>");//如何成对替换 [U]
str = Regex.Replace(str, @"/[i/](.*?)/[/i/]", "<i>$1</i>");//[i]
str = Regex.Replace(str, @"/[b/](.*?)/[/b/]", "<b>$1</b>");//[b]
//email 联接。。
str = Regex.Replace(str, @"/[email/](.*?)/'?/[/email/]", "<a href='mailto:$1'>$1</a>");//email
str = Regex.Replace(str, @"/[email=/'?(.*?)/](.*?)/[/email/]", "<a href='mailto:$1'>$2</a>");//email
str = Regex.Replace(str, @"/[url=/'?(.*?)/'?/](.*?)/[/url/]", "<a href='$1'>$2</a>");//url
str = Regex.Replace(str, @"/[url/](.*?)/[/url/]", "<a href='$1'>$1</a>");//url
string fly = "<marquee scrollamount=/"3/" behavior=/"alternate/" width=/"90%/">$1</marquee>";
str = Regex.Replace(str, @"/[fly](.*?)/[/fly/]", fly);//fly
string move = "<marquee scrollamount=/"3/">$1</marquee>";//move
str = Regex.Replace(str, @"/[move](.*?)/[/move/]", move);
string glow = "<table width=/"$1/" style=/"filter:Glow(Color=$2, Strength=$3)/"><tr><td>$4</td></tr></table>";
str = Regex.Replace(str, @"/[glow=(/d*?),(.*?),(/d*?)](.*?)/[/glow/]", glow);
string quote="<table width=/"100%/" cellpadding=/"5/" cellspacing=/"1/" border=/"0/"><tr><td bgcolor=/"#F3F3F3/">$1</td></tr></table>";
str = Regex.Replace(str, @"/[quote/](.*?)/[/quote/]", quote);//发光
string center = "<div align=$1>$2</div>";
str = Regex.Replace(str, @"/[align=/'?([center|right|left])/'?/](.*?)/[/align/]", center);//排列方式
return str ;
}
本文介绍了一种将简单文本标记转换为HTML富文本格式的方法,包括对文本中的各种标记进行解析并转换为相应的HTML标签,如加粗、斜体、下划线等。

1486

被折叠的 条评论
为什么被折叠?



