Recommend on Google

Search and replace any word or letter in a string, place the prototype on the first frame.

String.prototype.replace = function(str, rep) {
     return this.split(str).join(rep);
};

//use it like this
var myStr:String = "Hello earth!"
trace(myStr.replace("earth","world")
 

Leave a Comment