Friday, March 09, 2007

String Search and Replace


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")

No comments: