将下面
[table=100,red][tr][td]s1[/td][td]s2[/td][/tr][tr]sTest[td][/td][/tr][/table]
替换为
<table style='width:100;background-color:red'><tr><td>s1</td><td>s2</td></tr><tr><td>sTest</td></tr></table>
用正规表达式来搞.
单个TR/TD
[table=100,red][tr][td]s1[/td][/tr][/table]代码如下
string vstr="[table=100,red][tr][td]s1[/td][/tr][/table]";
objregex = new Regex(@"(\[table=(.[^\[]*),(.[^\[]*)\])(\[tr\])(\[td\])(.[^\[]*)(\[\/td\])(\[\/tr\])(\[\/table\])", RegexOptions.IgnoreCase);
vstr = objregex.Replace(vstr, @"<table style='width:$2;background-color:$3'><tr><td>$6</td></tr></table>");
我到是可以搞定,但是多个我就写不出来了,请大家帮忙看看
[table=100,red][tr][td]s1[/td][td]s2[/td][/tr][tr]sTest[td][/td][/tr][/table]
替换为
<table style='width:100;background-color:red'><tr><td>s1</td><td>s2</td></tr><tr><td>sTest</td></tr></table>
用正规表达式来搞.
单个TR/TD
[table=100,red][tr][td]s1[/td][/tr][/table]代码如下
string vstr="[table=100,red][tr][td]s1[/td][/tr][/table]";
objregex = new Regex(@"(\[table=(.[^\[]*),(.[^\[]*)\])(\[tr\])(\[td\])(.[^\[]*)(\[\/td\])(\[\/tr\])(\[\/table\])", RegexOptions.IgnoreCase);
vstr = objregex.Replace(vstr, @"<table style='width:$2;background-color:$3'><tr><td>$6</td></tr></table>");
我到是可以搞定,但是多个我就写不出来了,请大家帮忙看看
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货