NewSourceMedia on Facebook

Flash string search replace using prototype

Share Bookmark and Share

How to preform a string search and replace in flash using actionscript prototype
A prototype to replace a pattern in a string

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

To use the prototype

var str = "hello world";
var newstr = str.replace("world", "Earth");
trace(newstr);

This will output: Hello Earth

Please rate this post by clicking a star:

(1 votes, average: 5.00 out of 5)

Leave a Reply





Tags: , , , ,