Solved

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

Posted on 2004-10-20
8
606 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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/…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

896 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

14 Experts available now in Live!

Get 1:1 Help Now