471,339 Members | 1,349 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

how to remove line breaks/an enter in a string

How can I remove a line break/enter from a piece of text.

Thx in advance
Jul 2 '08 #1
4 11541
Richard wrote:
How can I remove a line break/enter from a piece of text.

Thx in advance

Lookup "regular expressions"
Jul 2 '08 #2
Richard presented the following explanation :
How can I remove a line break/enter from a piece of text.

Thx in advance
string s = @"a string
with linebreak";
s = s.Replace(Environment.NewLine, "");

Hans Kesting
Jul 2 '08 #3
On Jul 2, 4:02*am, Neo Morpheous <bluebp...@ursa-major.comwrote:
Richard wrote:
How can I remove a line break/enter from a piece of text.
Thx in advance

Lookup "regular expressions"
Hi,

I do not think that Regex will do any good here. a simple
String.Replace is enough.
You can look for Environment.NewLine.

A tricky situation happens though if the file was originated in a
system with a different NewLine sequence, you will replace nothing but
the text still do not look like you intented.

IMHO you should look for char# 13 and 10 and remove them.
Jul 2 '08 #4
On Wed, 02 Jul 2008 07:42:56 -0700, Ignacio Machin ( .NET/ C# MVP ) wrote:
IMHO you should look for char# 13 and 10 and remove them.
that should be characters \r and \n

I have worked with ebcdic before and it was one of my pet hates, for
example in c 0x20 is a space instead of simply using ' '. Made porting
interesting.

Jul 4 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Jon LaRosa | last post: by
2 posts views Thread by revjjjames | last post: by
5 posts views Thread by joelbyrd | last post: by
3 posts views Thread by nashak | last post: by
6 posts views Thread by Steve | last post: by

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.