[fwd] [thelist] Replacing Carriage returns in Javascript

Dave Dufour dave at du4.com
Tue Sep 18 09:36:51 CDT 2001


Matthias,

Thanks.  I've found a good solution using the escape sequences and
REPLACE -- this is it from a Google Groups page:

>>>>>>>>>>>>>>>>>>>>
With js1.2 use
  String.replace()
e.g.
  "line 1\nline2\nline3\n".replace(/\n/g, "")
Depending on what you regard as a carriage return (\r or \n or \r\n)
adapt the regular expression
  "line 1\nline2\nline3\n".replace(/\r|\n|\r\n/g, "")
>>>>>>>>>>>>>>>>>>>>

O'Reilly's provided some of this reference, but their examples were more
complex than I needed, so it was still a little confusing and it was hard to
locate the escape sequences you've provided here.  I'll hang on to this list
too.  Thanks for providing it.

Dave



>-----Original Message-----
>From: thelist-admin at lists.evolt.org
>[mailto:thelist-admin at lists.evolt.org]On Behalf Of Matthias Ritzkowski
>Sent: Tuesday, September 18, 2001 7:17 AM
>To: 'thelist at lists.evolt.org'
>Subject: RE: [fwd] [thelist] Replacing Carriage returns in Javascript
>
>
>Dave
>
>according to my magic book here, these are the escape
>sequences and their
>associated characters for JavaScript:
>
>\b	Backspace
>\f	Form feed
>\n	New line
>\r	Carriage return
>\t	Tab
>\'	Single Quote
>\"	Double Quote
>\\	Backslash
>
>Actually I am going to print this and hang it up as I only had
>the VBscript
>equivalents here so far ...
>Thanks for asking!
>
>Matthias
>
>
>
>
>-----Original Message-----
>From: Dave Dufour [mailto:dave at du4.com]
>Sent: Monday, September 17, 2001 22:05
>To: thelist at lists.evolt.org
>Subject: RE: [fwd] [thelist] Replacing Carriage returns in Javascript
>
>
>This is a remote scripting application that will only be
>viewed in IE 5.5,
>so I'm not worried about other browsers.  No, it's not
>publicly accessible.
>I'm passing values via javascript to an Active Server Pages
>remote script
>and if there are any carriage returns in the text being passed, the ASP
>function receiving it bombs.  No problem if the carriage returns are
>removed.  So, I figured a simple replace would solve the problem, but I
>cannot find the appropriate code to specify a carriage return in the
>string.replace function..
>
>---------------------------------------
>For unsubscribe and other options, including
>the Tip Harvester and archive of TheList go to:
>http://lists.evolt.org Workers of the Web, evolt !
>





More information about the thelist mailing list