(function ($) { $.fn.extend({ nFCReplaceAll:function(str,reallyDo, replaceWith){ return str.nReplaceAll(reallyDo, replaceWith); } }); }) // 替换所有 String.prototype.nReplaceAll = function(reallyDo, replaceWith, ignoreCase) { if (!RegExp.prototype.isPrototypeOf(reallyDo)) { return this.replace(new RegExp(reallyDo, (ignoreCase ? "gi" : "g")), replaceWith); } else { return this.replace(reallyDo, replaceWith); } };
var tempStr = '大家好,我想换行';
tempStr = tempStr .nReplaceAll(',','</br>,');// 调用方式1