内容标记HTML我的命令替换CKEditor的
var content = $('#editor1').val(); // With editor1 is my ckeditor
获得内容的CKEditor我收到这样<h3 class="Interview">any word(may be unicode)</h3>
字符串我怎样才能通过它的JavaScript来代替???? <h3 class="Interview">My word</h3>
请帮帮我!!!谢谢 !!!
内容标记HTML我的命令替换CKEditor的
var content = $('#editor1').val(); // With editor1 is my ckeditor
获得内容的CKEditor我收到这样<h3 class="Interview">any word(may be unicode)</h3>
字符串我怎样才能通过它的JavaScript来代替???? <h3 class="Interview">My word</h3>
请帮帮我!!!谢谢 !!!
这应该工作
result = subject.replace(/(<[a-z][a-z0-9]*[^<>]*>)([a-z][a-z0-9]*[^<>]*)(<\/?[a-z][a-z0-9]*[^<>]*>)/, "$1 My words $3");
您可以通过使用正则表达式:
var a = '<h3 class="Interview">any word(may be unicode)</h3>'
a = a.replace(/(<h3[^>]*>)[^<]*<\/h3>/g, '$1'+'your words</h3>')
试试这个:
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));