Solved
Replace paragraphs in TextArea with double line break?
Posted on 2008-10-12
I have a function, gleaned from an earlier ExEx thread, that takes html code from a database and shows it in plain-text format in a textarea.
Everything is working fine, except I want to have new paragraphs in the html replaced by *double* line returns in my text version .
I've spent forever trying various character combinations, and I can't get double-spacing to take hold.
Here is the function
function htmlToText(theHtml)
{ newP = chr(10) & chr(13) & chr(10) & chr(13);
theText = REReplaceNoCase(theHTML,"<a .*(href=['""]?)([^'"" ]+)['"" ][^>]+>([^<]+)</a>","\3: \2","all");
theText = REReplaceNoCase(theText,"<p[^>]*>",newP,"all");
theText = REReplaceNoCase(theText,"<[^>]+>","","all");
return theText;
}
As you can see I am trying to force a double line break, but the textarea still interprets this as a single line return.
If I insert any character between the two line returns, it gives me a new line, with the character, then another new line, as it should.
{ newP = chr(10) & chr(13) & '.' & chr(10) & chr(13);
but if I just have the two sets of line return characters, I only get one new line.
how can I force a double line replacement in my textarea?
I tried using a whitespace character like a 'space' between the lines, but that doesn't do anything, that i can tell.