[thelist] replacing CRLFs in Memo fields

Ian Anderson ian at zstudio.co.uk
Tue Mar 15 06:53:25 CST 2005


Hi Burhan

I wrote this function to do it in ASP Classic - you're welcome to try it 
if that's your environment

<% Function CleanLineBreaks(daTxt)
'this function finds double line breaks in the input text
'and replaces them with <p> tags. Single line breaks are
'replaced with <br>. <p> tags are closed properly.
'By Ian Anderson (ian at zstudio.co.uk) www.zstudio.co.uk
    daTxt = "<p>" & daTxt & "</p>"
    bStr = Chr(13) & Chr(10)
    pStr = Chr(13) & Chr(10) &  Chr(13) & Chr(10)
    daTxt = Replace(daTxt, pStr,"</p>" & vbCr & "<p>")
    daTxt = Replace(daTxt, bStr,"<br>" & vbCrLf)
    daTxt = Replace(daTxt, "<br>" & vbCrLf & "</p>", "</p>")
    CleanLineBreaks = daTxt

End Function
%>

Useage: <%=CleanLineBreaks(RS("memotext"))%>

HTH

Cheers

Ian Anderson


Burhan Khalid wrote:

> Pringle, Ron wrote:
>
>> Ok, two more related questions. I've googled around for this and haven't
>> come across anything. (any links would be appreciated).
>>
>> In my Access 2000 DB I have a memo field that will be taking input 
>> from a
>> web form. The people using the form will most likely be cutting and 
>> pasting
>> text from MS Word docs.
>>
>> That memo field will in turn be displayed on the web. I want to 
>> preserve the
>> paragraph formatting of the original text.
>>
>> 1. How do I go about finding and replacing the CLRFs that are 
>> inserted in
>> the form field with <p> tags?
>
>
> If you are using PHP, you can use the nl2br() function which will do 
> this for you (and you can preserve the original format in the database).
>
> As its name suggests, it converts newlines to break tags.
>
> Hope this helps





More information about the thelist mailing list