473,383 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Routine to remove extra newline chars and carriage return

I there a quick routine that removes trailing newline chars and
carriage return?

vFlyer Labs
http://www.vflyerlabs.com

May 30 '07 #1
5 13349
You can write one:

String.prototype.rtrim = function() {
return this.replace(/\n\r/,"");
}

May 30 '07 #2
On May 29, 8:11 pm, noagbodjivic...@gmail.com wrote:
You can write one:

String.prototype.rtrim = function() {
return this.replace(/\n\r/,"");}
String.prototype.rtrim = function() {
return this.replace(/[\n\r]/,"");
}

May 31 '07 #3
scripts.contact wrote:
On May 29, 8:11 pm, noagbodjivic...@gmail.com wrote:
You can write one:
String.prototype.rtrim = function() {
return this.replace(/\n\r/,"");}

String.prototype.rtrim = function() {
return this.replace(/[\n\r]/,"");}
No. The three most common EOLs are:

\n (Linefeed)
\r (Carriage return)
\r\n (Carriage return followed by linefeed)

But you also have:

NEL = Next Line (\u0085)
FF = Form Feed (\u000C)
LS = Line Separator (\u2028)
PS = Paragraph Separator (\u2029)

A fully backwards compatible, Unicode-compliant regexp would be:

/(\r\n|\r|\n|\u0085|\u000C|\u2028|\u2029)/g

--
Bart

May 31 '07 #4
On May 31, 2:29 pm, Bart Van der Donck <b...@nijlen.comwrote:
String.prototype.rtrim = function() {
return this.replace(/[\n\r]/,"");}
forgot the $ :
return this.replace(/[\n\r]$/,"");}

A fully backwards compatible, Unicode-compliant regexp would be:

/(\r\n|\r|\n|\u0085|\u000C|\u2028|\u2029)/g
/(\r\n|\r|\n|\u0085|\u000C|\u2028|\u2029)$/
May 31 '07 #5
On May 31, 2:29 pm, Bart Van der Donck <b...@nijlen.comwrote:
String.prototype.rtrim = function() {
return this.replace(/[\n\r]/,"");}
forgot the $ :
return this.replace(/[\n\r]$/,"");}

A fully backwards compatible, Unicode-compliant regexp would be:

/(\r\n|\r|\n|\u0085|\u000C|\u2028|\u2029)/g
/(\r\n|\r|\n|\u0085|\u000C|\u2028|\u2029)$/
Jun 1 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Tobiah | last post by:
This is a stumbling block for me. Is there a better way to output *just* what I want? I want the output "foobar" >>> print "foo"; print "bar" foo bar >>> print "foo",; print "bar"
5
by: Ron | last post by:
Greetings, I am writing text to a multi line textbox on a timer as follows: txt1.AppendText(@"/* " + DateTime.Now.ToString() + "\n"); Here is what gets displayed /* 1/1/2004 11:12:11 AM|
8
by: John Grandy | last post by:
in VB.NET you can do sb = New StringBuilder("Hello") sb.Append(vbCrLf) What is the C# analogy to vbCrLf ?
34
by: Registered User | last post by:
Hi experts, I'm trying to write a program that replaces two or more consecutive blanks in a string by a single blank. Here's what I did: #include <stdio.h> #include <string.h> #define MAX 80
2
by: Mike P | last post by:
How do you remove all chars such as carriage return and new line from a particular field for all records in a dataset? *** Sent via Developersdex http://www.developersdex.com ***
0
by: John Smith | last post by:
Hi, I am using XML XSL to create a CSV file using Transformation. But during the transformation all the Newline characters (CHR 10) is getting translated to Carriage Return and New Line (CHR 13...
4
by: whitej77777 | last post by:
I am trying to write a user defined function that will allow me to strip off the last carriage return and line feed from a text field. We have address fields stored in a text field for our ERP...
7
by: newbtemple | last post by:
Hey all. I'm having a bugger of a time trying to remove carriage returns. I have a large text file with a bunch of little squares. I'm guessing they're carriage returns from what i've googled. They...
4
by: lilly07 | last post by:
I am trying to remove all white spaces, tabs, newline, carriage return etc.. from a text file to make it as a one continous string. But the following code doesnot work. The file size is relatively...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.