Posted By

gandreini on 01/18/11


strip String regexp

Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


Strip whitespace at the beginning and the end of a string

 / Published in: ActionScript 3

This can be useful when you retrieve strings from an XML or script that have whitespaces at the beginning or the end.

  1. function stripBeginEndWhithespace(p_string:String):String
  2. {
  3. var pattern:RegExp = new RegExp("^[ \t
  4. ]+|[ \t
  5. ]+$","g");
  6. p_string = p_string.replace(pattern, "");
  7. return p_string;
  8. }

Report this snippet  

You need to login to post a comment.