I was working on a project for musicnation.com, their EPK. I had to render text in a textfield that was coming from an XML feed, text that is entered by users. It can be filled with different types of line feeds, notable the:
\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.
Here is my solution:
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.
Thanks for this mate!
Awesome, this was driving me mental !
thanks for this tip, very useful 🙂
thank you this was a great quick solution!
It also works to get rid of line breaks!
Very useful tip.
Thanks for sharing! =)
thanks for the tip!
RegExp are so usefull in many langages, but very tricky to implement…
You really saved my day! Great!!
Thanx = )
Thanks, works great!