Search and Replace

i am looking to create something similar to the str_replace function (from PHP) that will replace all occurrences of the search string the replacement string from within an larger string. Does anyone have something like that created already (save me the time)?

var myStr:String = new String( “i wish i were an oscar meyer weiner” );
var myOutput = str_replace(myStr, “i”, “we”);

// myOutput would now = “we wish we were an oscar meyer weiner”