Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

formatting multiline string

Posted on 2003-11-06
7
Medium Priority
?
414 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
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 34

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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 3

Accepted Solution

by:
monvelasquez earned 500 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 34

Author Comment

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

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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/…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

877 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