问题:[img]/uploadpic/2007-5/200757132236554.jpg[/img]替换成<img src=/uploadpic/2007-5/200757132236554.jpg>
解决办法:
using system.text.regularexpressions;
chr = new regex(@"(/[img/])([ /s/t]*?)(/[//img/])",regexoptions.ignorecase); 
for (m = chr.match(result); m.success; m = m.nextmatch()) 
{ 
result = result.replace(m.groups[0].tostring(), 
"<img src=/""+m.groups[2].tostring()+"/" border=0>"); 
} 
c# 提取子匹配字符串的例子
string ll="<td>([//s//s]*?)</td>"; 
regex r = new regex(ll); //定义组 
   match m = r.match("<tr class=alt><td>解读 c# 中的正则表达式</td>"); 
response.write(m.groups[0].value);
显示结果为" 解读 c# 中的正则表达式"
 
新闻热点
疑难解答