Skip to main content
Inspiring
June 17, 2010
Answered

ReReplace Best Practices Question

  • June 17, 2010
  • 2 replies
  • 806 views

On my page I have a form with a text area. I want to replace any ampersands and quotes with the proper code. My question is, is it better to run the rereplace as I take the formdata and store it in my database or do I handle that in the query when CF assembles the page?

Thank you for any help/advice

    This topic has been closed for replies.
    Correct answer ilssac

    That is the way it is being used NOW.

    I think you will find that as organizations acquire more data that find more ways to use the data in the future.

    So the general rule of thumb is to store the data as neutrally as possible, and format it for the desired display when it is being displayed,  In this case as html.  Thus, when that time comes in the future that they want to disply some in some other manner you won't be caught with the problem of deconstruction the HTML stored in the database and converting it to some other format.

    2 replies

    Inspiring
    June 17, 2010

    Another approach is to forget about regexes and use htmleditformat when displaying your data.  The html pre tag also comes in handy for preserving carraige returns and such.

    OfeargallAuthor
    Inspiring
    June 17, 2010

    I should point out that the textarea is in place for the client to update/edit page content that will be displayed.

    ilssac
    ilssacCorrect answer
    Inspiring
    June 17, 2010

    That is the way it is being used NOW.

    I think you will find that as organizations acquire more data that find more ways to use the data in the future.

    So the general rule of thumb is to store the data as neutrally as possible, and format it for the desired display when it is being displayed,  In this case as html.  Thus, when that time comes in the future that they want to disply some in some other manner you won't be caught with the problem of deconstruction the HTML stored in the database and converting it to some other format.

    OfeargallAuthor
    Inspiring
    June 17, 2010

    Ian,

    Thanks for that. I was a bit hesitant to store html in my database. Although my biggest concern was potential conflicts with the SQL but, as you point out, it's more about the usability of the data in the long run.

    I suspect I'll have more questions about regex as I get further into it. I don't fully understand the syntax yet but I haven't really applied it just yet. Mybe Lynda.com has something on regex.

    Thank you again.