Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

formatting multiline string

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

Author Comment

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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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/…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

730 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