Skip to content

Instantly share code, notes, and snippets.

@liuzhuan
Last active August 29, 2015 14:11
Show Gist options
  • Save liuzhuan/558bf47f828560742825 to your computer and use it in GitHub Desktop.
Save liuzhuan/558bf47f828560742825 to your computer and use it in GitHub Desktop.
function trim(str:String):String {
return str.replace(/^\s+/, "").replace(/\s+$/, "");
}
var demo:String = " foo bar ";
trace("["+demo+"]"); // [ foo bar ]
trace("["+trim(demo)+"]"); // [foo bar]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment