Implement the replaceAll () function of the String object in JavaScript, the string. replace Function
In the JavaScript scripting language, it is certainly no stranger to using the replace () function for String objects, but there is no such method as the replaceAll () method in Java, but in use, it will inevitably be used. In this case, only our programmers can do it themselves !!
/*** Author Joyce. luo 10:19:54 prepared in 2015.01.05 * JavaScript language Methods: replaceAll (), based on the replace () method to realize * @ param {} rgExp The need to replace the string or regular object * @ param {} replaceText The string matching to replace the string * @ return {} Returns a new string replacement */String. prototype. replaceAll = function (rgExp, replaceText) {return this. replace (new RegExp (rgExp, 'GM '), replaceText );};
The effect is simple and clear .....