ExtString class from mx.community.com

The ExtString class extends the ActionScript String class and contains one method only. It’s a really sweet little method for finding and replacing all occurences of a String within an ExtString.

Here’s the class, in all it’s simplicity.

class com.communitymx.Utils.ExtString extends String {
	function ExtString(str){
	public function findReplace(sFind:String, sReplace:String):String {
		return this.split( sFind ).join( sReplace);


Very nice find and replace: no looping, no storing indices. Here’s how that method works:

The following code stretches out the steps, using some plain old Strings and an Array. Makes the process more explicit. (Paste it into a new Flash file and watch it work.)

This entry was posted in flash, actionscript, flex. Bookmark the permalink.