我想将
<pre class="prettyprint lang-runCode">
xxxx
</pre>
替换成
[html]xxxx[/html]
此正则如何写?
xxx是html代码下面是一个实例代码
<pre class="prettyprint lang-runCode">&lt;script language=&quot;javascript&quot;&gt;
function $(e){return document.getElementById(e);}
function $$(tag,name){
    var all = new Array();
    var tags = document.getElementsByTagName(tag);
    for(var i=0; i&lt;tags.length; i++){
        if(tags[i].name==name)
        all[all.length]=tags[i];
    }
    return all;
}
function add(){
    $('test').innerHTML+='输入律师姓名:&lt;br /&gt;&lt;input name=&quot;lawyer[]&quot; type=&quot;text&quot; size=&quot;15&quot; /&gt;&lt;br /&gt;';
}
function check(){
    var chks = $$('input','lawyer[]');
    if(chks.length){
        for(var i=0;i&lt;chks.length;i++){
            if(chks[i].value=='')
            alert('第'+(i+1)+'个表单没有填写!')
        }
    }else{
        alert('您还没有添加表单!');
    }
}
&lt;/script&gt;
&lt;button onclick=&quot;add()&quot;&gt;添加一个表单&lt;/button&gt;
&lt;div id=&quot;test&quot;&gt;&lt;/div&gt;
&lt;button onclick=&quot;check()&quot;&gt;提交&lt;/button&gt;</pre>
我想将

解决方案 »

  1.   

    我这样写不对
    re.Pattern="(\<pre class=""prettyprint lang-runCode""\>)(.+?)(\<\/pre\>)"
    body=re.Replace(body,"<font size=5>$2</font>")
      

  2.   

    已经弄好
    这样就可以了
    re.Pattern="(\<pre class=""prettyprint lang-runCode""\>)([\s\S]*?)(\<\/pre\>)"
      

  3.   

    Regex reg = new Regex(@"(?is)<pre class=""prettyprint lang-runCode"">(.*?)</pre>");
    string result = reg.Replace(yourStr, "[html]$1[/html]");
      

  4.   

    应该这样

    re.Pattern="(\<pre class=""prettyprint lang-runCode""\>)([\s\S]*?)(\<\/pre\>)"
    因为.不能代表换行等所以中间有多行复杂代码的时候匹配不上。
    还是很感谢。