/ Published in: ActionScript 3
\n = linux \r = mac (prior to macos being based on freebsd I guess) \r\n = the damned pc linefeed.
The TextField object in Flash seems to render both \r and \n as linefeeds. Therefore I was getting way too many linefeeds in my rendered text.
Tada! _text is of type String. The /g is VERY important at the end of the declaration of the RegExp, it means it will replace ALL instances. If you do not put /g it wont.
Expand |
Embed | Plain Text
var pcLB:RegExp = / /g; var macLB:RegExp = /\r/g; var linuxLB:RegExp = /\n/g; text = _text.replace(pcLB, "\n"); text = _text.replace(macLB, "\n");
Comments
Subscribe to comments
You need to login to post a comment.

an old scholl way of doing it could be something like this:
myString= myString.split("\r\n").join("\n");
Dunno if it's slower?
This is more fancy ;)