?
Solved

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

Posted on 2004-10-20
8
Medium Priority
?
621 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
Independent Software Vendors: 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

Technology Partners: 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!

Question has a verified solution.

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

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

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