remove ascii text formatting

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

This is useful if you are loading html-text via XML and want to remove additional line-breaks, newlines, formfeeds and tabs. It just leaves the clean html.

Copy this code and paste it in your HTML
  1. public static function removeAsciiFormatting(str:String):String {
  2. if (str != null) {
  3. var pattern:RegExp = /(\t|\n|\f|\r)*/gm; // remove tabs, newlines, formfeeds and returns
  4. return str.replace(pattern, '');
  5. } else {
  6. return null;
  7. }
  8. }

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.