Return to Snippet

Revision: 43684
at March 29, 2011 16:28 by konrad_ha


Updated Code
public static function removeAsciiFormatting(str:String):String {
	if (str != null) {
		var pattern:RegExp = /(\t|\n|\f|\r)*/gm; // remove tabs, newlines, formfeeds and returns
		return str.replace(pattern, '');
	} else {
	        return null;
	}
}

Revision: 43683
at March 29, 2011 16:27 by konrad_ha


Initial Code
public static function removeAsciiFormatting(str:String):String {
			if (str != null) {
				var pattern:RegExp = /(\t|\n|\f|\r)*/gm; // remove tabs, newlines, formfeeds und returns
				return str.replace(pattern, '');
			} else {
				return null;
			}
		}

Initial URL


Initial Description
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.

Initial Title
remove ascii text formatting

Initial Tags
text

Initial Language
ActionScript 3