By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,424 Members | 1,375 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,424 IT Pros & Developers. It's quick & easy.

how to remove line breaks/an enter in a string

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

Thx in advance
Jul 2 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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.