how to remove line breaks/an enter in a string

  • Thread starter Thread starter Richard
  • Start date Start date
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
 
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.
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top