function strReplace(str:String, search:String, replace:String):String {
return str.split(search).join(replace);
}
return str.split(search).join(replace);
}
Description: A function used for replacing portions of a string with a new one. Note that this function does not modify the original string.
Parameters:
str:String – The string to have portions replaced.
search:String – The string to search for and replace in str.
replace:String – The string which is placed where the search string is found.
Returns:
String – The original string with portions replaced.
Example Usage:
var str:String = “Hello World!”;
trace(strReplace(str, “Hello”, “Goodbye”)); //outputs Goodbye World!
trace(str); //outputs Hello World!
trace(strReplace(str, “Hello”, “Goodbye”)); //outputs Goodbye World!
trace(str); //outputs Hello World!
This entry was posted on Monday, October 19th, 2009 at 5:54 pm and is filed under ActionScript, Flash, Tutorials. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.
You might also like
| getting past IE popup blocker ActionScript3 can use this fix to bypass popups in IE… /* use this snippet in the as file to work with this class ... | Tricks and Experiments , AS3 Tips As you read each of the following descriptions, consider opening Flash, pasting the code into timeline script and... | Using other types within ActionScript packages I was doing something, I forget what it was now, but it got me curious about functions defined in some of the... | Check Valid Email in AS3 Where construction of forms in Flash is required to whether the email account is entered correctly or not do this... |







