Solved

formatting multiline string

Posted on 2003-11-06
7
411 Views
Last Modified: 2008-03-04
Say I have the following string:

This is a
multi-line string
that should
be one line.

How do I get it to one line?

I've tried replace(string, CHR10, "\n") and replace(string, CHR13, "\n") and replace(string, vbcrLf, "\n") to no avail.

This text is coming from an Err.Description and going to be put into a session variable and then displayed in javascript on the next page.

Thanx in advance
B.D.
0
Comment
Question by:Big Monty
[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
7 Comments
 
LVL 23

Expert Comment

by:Saqib Khan
ID: 9697521
try this

replace(string, vbcrLf, "")

in your code you are replacing the LINE BREAK with the LINE BREAK(\n). try using a empty String.
0
 
LVL 12

Expert Comment

by:kingsfan76
ID: 9697525
I think "\n" is a new line character for javascript.
try to replace it with an empty space "" and see if it works
0
 
LVL 33

Author Comment

by:Big Monty
ID: 9697624
i want it to be a new line break because if i don't, then it shows up in javascript like:

alert("this is the error message
that i got from err.description. you see how
it keeps going like this?")

as you can tell this is not a valid javascript alert message. my theory was that if i translated the line breaks into \n, then i would reserve the format
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 3

Accepted Solution

by:
monvelasquez earned 125 total points
ID: 9699125
i think you need something like...

--[CODE]--------------------------------------------------------
Replace(asp_string_var, vbCrLf, "\n")
--[/CODE]--------------------------------------------------------

to use this in javascript use it like this..

--[CODE]--------------------------------------------------------
<script language="javascript">

alert("<%=Replace(asp_string_var, vbCrLf, "\n")%>");

</script>
--[/CODE]--------------------------------------------------------

However you still need to take care of quotes...

so you need..

--[CODE]--------------------------------------------------------
<%
jscript_string = Replace(asp_string_var, vbCrLf, "\n")
jscript_string = Replace(jscript_string, """", "\""")
%>
...some code here....
<script language="javascript">

alert("<%=jscript_string%>");

</script>
--[/CODE]-------------------------------------------------------



hope this helps..

____________
Raymond:\>_
0
 
LVL 15

Expert Comment

by:deighc
ID: 9702378
I'm surprised that

replace(string, vbcrLf, "\n")

doesn't work. Perhaps you should try

replace(string, vbLf, "\n")

instead. May the text lines output from the error object are seperated only be a line feed (vbLf) rather than a carriage return line feed (vbCrLf).
0
 
LVL 28

Expert Comment

by:sybe
ID: 9703619
Replace(string, CHR(13) & CHR10, "\n")
0
 
LVL 33

Author Comment

by:Big Monty
ID: 10561766
forgot i left this open so i decided to clean up now
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

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…
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

751 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