[as3]

var rex:RegExp = /[\s\r\n]+/gim;
var str:String = "This is a string.";

str = str.replace(rex,”);
// str is now "Thisisastring."

[/as3]

For trimming front and back of strings, use
[as3]

var rex:RegExp /^\s*|\s*$/gim;

[/as3]

[as3]
//A simple demo that shows how to pan from one side of an object to another dynamically in actionscript 3.

//demo at: http://www.adamcoulombe.info/lab/as3/sliderbox.html

import fl.transitions.Tween;
import fl.motion.easing.*;
import fl.transitions.TweenEvent;

var sliderBoxTween:Tween

stage.addEventListener(MouseEvent.MOUSE_MOVE,mouseMoved)

function mouseMoved(e){
var xPercent = mouseX / stage.stageWidth;
var newXPos = (stage.stageWidth – sliderBox.width) * xPercent;
sliderBoxTween = new Tween(sliderBox, "x", Circular.easeOut, sliderBox.x, newXPos, 1, true);
}
[/as3]

[as3]
var functionGoFast:Function = goFast("yes");
checkBoxFast.addEventListener(clickType, functionGoFast);

function goFast(myVar:String):Function {
return function(evt:Event = null):void {
trace(myVar);
}
}

//checkBoxFast.removeEventListener(clickType, functionGoFast);
[/as3]

[as3]
// import flash.filters.ColorMatrixFilter;

function blackAndWhite($target:DisplayObject, $enabled:Boolean):void
{
var rc:Number = 1/3;
var gc:Number = 1/3;
var bc:Number = 1/3;
var cmf:ColorMatrixFilter = new ColorMatrixFilter([rc, gc, bc, 0, 0, rc, gc, bc, 0, 0, rc, gc, bc, 0, 0, 0, 0, 0, 1, 0]);

if ($enabled) {
$target.filters = [cmf];
} else {
$target.filters = [];
}
}

blackAndWhite(myMovieClip, true);
[/as3]