Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6064253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:15:36+00:00 2026-05-23T09:15:36+00:00

I store the htmlText property of a RichTextEditor in the database. I retrieve it

  • 0

I store the htmlText property of a RichTextEditor in the database.

I retrieve it in another instance and I want to show the user the first line of it as plain text

So I let Flex handle the conversion by using a function like this

var editor:TextField = new TextField();
editor.htmlText = htmlTextFromDb;
var converted:String = editor.text;

However, the issue is that this conversion does not handle lines properly. I get everything in one line!

Lets say what I get from the database is this

<TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Arial" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">This is line one</FONT></P></TEXTFORMAT><TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Arial" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">This is line two</FONT></P></TEXTFORMAT>

As soon as I say editor.htmlText = htmlTextFromDb, editor.htmlText becomes

<TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Arial" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">This is line oneThis is line two</FONT></P></TEXTFORMAT>

It acts as if new lines are not present.

How do I solve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:15:37+00:00Added an answer on May 23, 2026 at 9:15 am

    I would think about server side conversion of this HTML text.

    But in AS only you could do it line by line by splitting on line break, then converting the line to text and after this concatenating all. A bit ugly, but should work.

    var editor:TextField = new TextField();
    var result:Array = new Array();
    var input:Array = htmlTextFromDb.split(/\n/);
    for each( var line:String in input) {
        editor.htmlText = line;
        result.push(editor.text);
    }
    var converted:String = result.join("\n");
    

    edit

    Replacing the tags with regular expression would be another way. First replace the closing paragraph </P> with a line break, and then remove all remaining tags.

    var lnRegExp:RegExp = new RegExp("</P>", "g");
    s = s.replace(lnRegExp, "\n");
    var tagRegExp:RegExp = new RegExp("<([^>\\s]+)(\\s[^>]+)*>", "g");
    trace(s.replace(tagRegExp, ""));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There is some html text stored in the Database which I want to show
I store various user details in my MySQL database. Originally it was set up
I store some dates in my NSMutableArray, I want to retrieve them and change
I store user data in a MSSQL table called Users. What I want to
I store serialized data in the registry. I want to use a foreach loop
I store file’s attributes (size, update time…) in database. So the problem is how
I store rdl's remotely in a sql server database in binary format. I would
I store user-uploaded images in the Google App Engine datastore as db.Blob , as
We store a decimal(9,8) in our database. It can have any number of places
We store all our dates SQL Server 2008 database in UTC time in DateTime

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.