« Strip Html Tags - with allowable tags
» External Flex Project

ActionScript, How to

nl2br - New Line To BR

09.04.08 | Comment?

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.

Popularity: 57%

Share and Enjoy:
  • Technorati
  • StumbleUpon
  • del.icio.us
  • NewsVine
  • Reddit
  • Digg
  • Furl
  • co.mments
  • blogmarks
  • Slashdot
  • DZone
  • Taggly
  • YahooMyWeb
  • connotea
  • Webride
nl_to_br_source
nl_to_br




Tags: , ,

This post was written by Andrei Ionescu

Views: 1411

related

popular

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>

:

:


« Strip Html Tags - with allowable tags
» External Flex Project