Solved

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

Posted on 2004-10-20
8
612 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Save ms data to server side. 19 63
asp classic find word in string and get its value 7 48
href return to normal window 5 43
ASP and Extracting XML 7 44
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

739 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