Skip to content

Instantly share code, notes, and snippets.

@geraldyeo
Created January 4, 2011 03:42
Show Gist options
  • Save geraldyeo/764356 to your computer and use it in GitHub Desktop.
Save geraldyeo/764356 to your computer and use it in GitHub Desktop.
REPLACING LINE BREAKS IN ACTIONSCRIPT
// here's a quick code snippet to replace windows-style line breaks (CRLF, or carriage return, line feed) with a standard
// actionscript new line character.
var newText:String = oldText.replace(/\r\n/g, "\n");
// and here's a snippet to replace all multiple line breaks with a single new line character:
var newText:String = oldText.replace(/[\r\n]+/g, "\n");
// for example, the preceding code would change the following string:
// a
//
//
// b
//
// to this:
// a
// b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment