/g(全局)标记在jquery.replace函数中不起作用
我想要的是:/g(全局)标记在jquery.replace函数中不起作用,jquery,replace,find,Jquery,Replace,Find,我想要的是: This%2520is%2520the%2520 %2520thing%2520 %2520purchased%2520 这是我的密码。我的问题是/g标记(全局)似乎不起作用 This is the thing purchased oldhtml=$('#description').html(); var newhtml=oldhtml.replace(“%2520”/g,”); $('#description').html(newhtml); 代替“,添加/以涵盖正则表
This%2520is%2520the%2520 %2520thing%2520 %2520purchased%2520
这是我的密码。我的问题是/g标记(全局)似乎不起作用
This is the thing purchased
oldhtml=$('#description').html();
var newhtml=oldhtml.replace(“%2520”/g,”);
$('#description').html(newhtml);
代替“,添加/
以涵盖正则表达式。
即/%2520/g
使用%2520'/g时,没有可关联的正则表达式
<script>
oldhtml = $('#description').html();
var newhtml = oldhtml.replace("%2520"/g, " ");
$('#description').html(newhtml);
</script>
或者,您可以使用
var newhtml = oldhtml.replace(/%2520/g, " ");
$('#description').html(newhtml);
var newhtml = oldhtml.replace(/%2520/g, " ");
$('#description').html(newhtml);
.replaceAll("%2520"," ");