要匹配的标签如下:
<input name="rptQuestions:_ctl0:txtQuestionType" type="text" value="1" id="rptQuestions__ctl0_txtQuestionType" style="width:0px;" />
<input name="rptQuestions:_ctl0:txtQuestionTypes" type="text" value="56" id="rptQuestions__ctl0_txtQuestionTypes" style="width:0px;" />匹配整个标签,我要把字符合条件的标签删除。
其中主要以name和id中的txtQuestionType 做主要标识改怎么样写正则表达式才可以删除name和ID中存在txtQuestionType   的整个标签

解决方案 »

  1.   

      var s='<input name="rptQuestions:_ctl0:txtQuestionType" type="text" value="1" id="rptQuestions__ctl0_txtQuestionType" style="width:0px;" /><input name="rptQuestions:_ctl0:txtQuestionTypes" type="text" value="56" id="rptQuestions__ctl0_txtQuestionTypes" style="width:0px;" />'
    var p=/<input\s*name=".*?(?:txtQuestionType)"[^>]*>/gi;
    alert(s.replace(p,''));
      

  2.   

    如果用jQuery的话:
    $("input[name^='rptQuestions'][id=^='rptQuestions']").remove();
    “^=”配置以属性以给定字符串开头的元素
      

  3.   

    错了,应该$("input[name*='txtQuestionType'][id=*='txtQuestionType']").remove();
    删除name或id包含txtQuestionType的input元素