2017-08-15 91 views

回答

0

截至更换所有问题的字符。

String.prototype.replaceAll = function(str1, str2, ignore) 
{ 
    return this.replace(new RegExp(str1.replace(/([\,\!\\\^\$\{\}\[\]\(\)\.\*\+\?\|\<\>\-\&])/g, function(c){return "\\" + c;}), "g"+(ignore?"i":"")), str2); 
}; 

然后对于每个文本单元格:

function cleanHTML(input) { 
    var output = input.replaceAll('“','"'); 
    output = output.replaceAll('”', '"'); 
    output = output.replaceAll("’", "'"); 
    output = output.replaceAll("‘", "'"); 
    output = output.replaceAll("", "'"); 
    output = output.replaceAll("", "-"); 
    output = output.replaceAll("", "'"); 
    return output; 
} 

无论其他章程将在稍后显示,我将为其添加一个替换。 希望有人会从中受益。