我通过命令
获取ckeditor中的内容 var content = $('#editor1').val(); // With editor1 is my ckeditor
我收到一个像<h3 class="Interview">any word(may be unicode)</h3>
这样的字符串
如何通过javascript ????
<h3 class="Interview">My word</h3>
请帮帮我!!!谢谢!!!
答案 0 :(得分:0)
这应该有效
result = subject.replace(/(<[a-z][a-z0-9]*[^<>]*>)([a-z][a-z0-9]*[^<>]*)(<\/?[a-z][a-z0-9]*[^<>]*>)/, "$1 My words $3");
答案 1 :(得分:0)
您可以使用regexp:
来实现var a = '<h3 class="Interview">any word(may be unicode)</h3>'
a = a.replace(/(<h3[^>]*>)[^<]*<\/h3>/g, '$1'+'your words</h3>')
答案 2 :(得分:0)
试试这个:
var str="<h3 class=\"Interview\">any word(may be unicode)</h3>";
function htmlTextReplace(original){
var regex = />([^<]*)</g;
return original.replace(regex, function($0, $1){
return $0.replace($1, strTextReplace($1, 'any word','your words'));
});
}
function strTextReplace(str, ow, dw){
return str.replace(ow, dw);
}
console.log(htmlTextReplace(str));