Fx{r} is trying to start the Fx{r} Community! Please join our group on Adobe Groups following this link: http://groups.adobe.com/groups/ab29539ab9.
Fx{r} is now on Twitter too. Follow us @ twitter.com/fx_r!
«
»

ActionScript, How to

nl2br – New Line To BR

Andrei Ionescu | 09.04.08 | 4 Comments

Google Buzz

Programmers with PHP background may miss some great functions that would make programmers life much easier (nl2br in PHP). Working with HTML in Flex is a big task and as you found in the previous article more functions are needed to process HTML strings.

In this article a simple function will transform any new line to a <br> tag.

public function nl2br(str:String):String
{
    return str.replace(new RegExp("[\n\r]","g"),"<br>");
}

Very simple. Just a single RegExp.

Share and Enjoy:
  • Twitter
  • Google Buzz
  • LinkedIn
  • Google Bookmarks
  • del.icio.us
  • Digg
  • Sphinn
  • blogmarks
  • Reddit
  • StumbleUpon
  • Facebook
  • DZone
  • FriendFeed
  • Yahoo! Buzz
  • Yahoo! Bookmarks
  • Slashdot
  • MySpace
  • Add to favorites
nl_to_br_source
nl_to_br




Tags: , ,

This post was written by Andrei Ionescu

Views: 6640

related

4 Comments

have your say

Add your comment below, or trackback from your own site. Subscribe to these comments.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

:

:


«
»