Strip whitespace at the beginning and the end of a string

/ Published in: ActionScript 3
Save to your folder(s)

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

Copy this code and paste it in your HTML
  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


RSS Icon Subscribe to comments

You need to login to post a comment.