Posted By

adrianparr on 05/10/10


Tagged

regex replace trim space whitespace regexp remove right Left as3 before after


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

tspitzr


AS3 Trim Whitespace From the Beginning and End of a String


 / Published in: ActionScript 3
 

  1. function trimWhitespace($string:String):String {
  2. if ($string == null) {
  3. return "";
  4. }
  5. return $string.replace(/^\s+|\s+$/g, "");
  6. }
  7.  
  8. var myString:String = " Hello World ";
  9. trace(trimWhitespace(myString));
  10. // OUTPUT
  11. // Hello World

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: bharathabk on May 22, 2012

Its working Thanks

You need to login to post a comment.