实现JavaScript中String对象的replaceAll()函数

JavaScript脚本语言中,大家对String对象使用replace()函数肯定不陌生,但是却没有如Java语言一般有replaceAll()方法,但是在使用中,又不可避免的会使用到,这种时候当然只有我们程序员自己来动手咯!!

/** * 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);};效果简单明了。。。。。

,孑然一身,隐入苍茫自然,自有一种孤独的意味;旅行,

实现JavaScript中String对象的replaceAll()函数

相关文章:

你感兴趣的文章:

标签云: