Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/425.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript正则表达式替换在IE10中不起作用_Javascript_Jquery_Regex_Internet Explorer - Fatal编程技术网

Javascript正则表达式替换在IE10中不起作用

Javascript正则表达式替换在IE10中不起作用,javascript,jquery,regex,internet-explorer,Javascript,Jquery,Regex,Internet Explorer,以下JS在FF中运行良好,但不能替代IE10中的任何内容: var pattern = new RegExp('<span id=\"(.+?)\" class=\"questiontext\"><p(.*?)>(.+?)<\/p><\/span>', 'gim'); $('.questiontext_div').html(function(index, html) { return html.replace(pattern,'<span i

以下JS在FF中运行良好,但不能替代IE10中的任何内容:

var pattern = new RegExp('<span id=\"(.+?)\" class=\"questiontext\"><p(.*?)>(.+?)<\/p><\/span>', 'gim');
$('.questiontext_div').html(function(index, html) { return html.replace(pattern,'<span id="$1" class="questiontext"><legend>$3</legend></span>'); });
var模式=新的RegExp(“(.+?)”,“gim”);
$('.questiontext_div').html(函数(索引,html){返回html.replace(模式,'$3');});
我正在尝试用图例替换p

<div class="questiontext_div">
  <span id="C00B7205241531FD2BEF31301000101F0DESC" class="questiontext">
     <P style="font-weight: bold; color: #005881;">Text will go here!</P>
  </span>
</div>

文本将转到此处


这可能更简单:

$('span.questiontext p').replaceWith('<legend...etc>');
$('span.questiontext p')。替换为('';

并在所有浏览器上工作

为什么!!!!???您正在使用jquery。当jquery使这种dom操作变得微不足道时,为什么要使用正则表达式?谢谢,这就是我最后使用的:$('span.questiontext p').replaceWith(function(){return'+this.innerHTML+'});