Posted By

konrad_ha on 03/29/11


Tagged

text newlines tabs formatting as3 line-breaks


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Demian


remove ascii text formatting


 / Published in: ActionScript 3
 

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.

  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  

You need to login to post a comment.