Skip to main content
WolfShade
Legend
August 8, 2012
Answered

REreplaceNoCase and "<br />" issue

  • August 8, 2012
  • 2 replies
  • 707 views

Hello, everyone.

I am using JavaScript to replace line breaks from a textarea with "<br />" before submitting the form, and that part is working flawlessly.

Where I'm having an issue is trying to replace the "<br />" with chr(13) & chr(10) in the data pulled from the database when trying to edit the value.  I'm using REreplaceNoCase() but I'm not sure how to tell the CF RegEx engine what to look for.

Here is what I'm using to insert the line breaks for HTML:

document.formName.fieldName.value = document.formName.fieldName.value.replace(/(\r\n|\r|\n)/g,"<br />");

Here is how I'm attempting to reformat for editing inside the textarea:

#REreplaceNoCase(qry.columnName,"<br />",chr(13) & chr(10),"all")#

But the REreplaceNoCase isn't finding any of the "<br />" that is in the value.  How should the RegEx be formatted to find the "<br />"?

Respectfully,

^_^

    This topic has been closed for replies.
    Correct answer WolfShade

    I have a habit of just automatically going for the RegEx solution, whenever possible.  Switching to ReplaceNoCase() didn't immediately correct the issue.

    Turns out that the "<br />", without my immediately realizing it, was being inserted into the database as "&lt;br /&gt;".  Once I figured that out, the suggestion of using ReplaceNoCase() worked.

    Thank you, guys.

    ^_^

    2 replies

    Inspiring
    August 8, 2012

    I'd use replace instead of rereplace for something that simple.

    WolfShade
    WolfShadeAuthorCorrect answer
    Legend
    August 8, 2012

    I have a habit of just automatically going for the RegEx solution, whenever possible.  Switching to ReplaceNoCase() didn't immediately correct the issue.

    Turns out that the "<br />", without my immediately realizing it, was being inserted into the database as "&lt;br /&gt;".  Once I figured that out, the suggestion of using ReplaceNoCase() worked.

    Thank you, guys.

    ^_^

    Miguel-F
    Inspiring
    August 8, 2012

    I think the issue is that you are using REreplaceNoCase but you are not specifying a regular expression.  Why not try using just ReplaceNoCase exactly as you have.  I think that will work for you.