Solved

Replace line breaks in Access memo fields with "<br>"?

Posted on 2004-10-20
8
605 Views
Last Modified: 2006-11-17
I have made function in ASP Jscript to replace line breaks in multiline memo field but it replace only  first line break. How to make it to replace the rest of line breaks?
( Chr(10) and Chr(13) does not work so i have  put "\n" instead. )

here is code:
while(!recordset.EOF){

          memo=recordset("description").Value;
          memo=memo.replace("\n","<br>");
          Response.Write(memo);


recordset.MoveNext();
      }
            recordset.Close();
}



0
Comment
Question by:xalexas
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 13

Expert Comment

by:nurbek
ID: 12356805
try this

memo = Replace(recordset("description").Value, VbCrlf, "<br>")
0
 
LVL 13

Expert Comment

by:nurbek
ID: 12356817
         memo=recordset("description").Value;
          memo=memo.replace(VbCrlf,"<br>");
          Response.Write(memo);
0
 
LVL 15

Accepted Solution

by:
Colosseo earned 250 total points
ID: 12356819
Hi there

try using this instead for your replace

should replace all instances for you

memo=memo.replace(/\n/g,"<br>");

Cheers

Scott
0
 
LVL 28

Expert Comment

by:sybe
ID: 12356861
i'd say it should be something like this:

var reg = /\n/;
while(!recordset.EOF){

    memo=recordset("description").Value;
    memo=memo.replace(reg,"<br>");
    Response.Write(memo);


    recordset.MoveNext();
}
recordset.Close();
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 15

Expert Comment

by:Colosseo
ID: 12356888
sybe: you need the regexp to be /\n/g : the g makes it global and replaces all instances rather than just the first one

/\n/ is effectively just the same as "\n"

Cheers

Scott
0
 

Author Comment

by:xalexas
ID: 12356914
Thanks Collosseo that was very fast! /\n/g, did the trick!
0
 
LVL 15

Expert Comment

by:Colosseo
ID: 12356921
Your welcome mate, and thanks for the grade

Cheers

Scott
0
 
LVL 28

Expert Comment

by:sybe
ID: 12357063
@Colosseo

I did not see your post before i posted mine, if i had, i would not have posted it. It was not a correction on your post, but trying to find an answer. And it was close, but not correct.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now