Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

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

Posted on 2004-10-20
8
Medium Priority
?
628 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 1000 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
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/…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

647 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