473,396 Members | 1,917 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,396 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 11742
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Jon LaRosa | last post by:
I'm am trying to remove multiple line breaks ("\n"). Here's my code: $imageStr = trim($_POST); $imageStr = str_replace("\n\n", "\n", $imageStr); ---------- $_POST is a textarea field, and...
2
by: revjjjames | last post by:
Hello - What is the correct expression to remove any extra line breaks beyond two in a string? Sincerely, Jim
4
by: Travis Pupkin | last post by:
Hi, I'm putting together a site to allow someone to add content to a DB through a text area form, and then display it on the web. Pretty basic. The problem I'm having is that they need to add...
4
by: intl04 | last post by:
I have a memo field that is included in some Access reports I created. Is there some way for the memo field to display nicely formatted text, with line breaks between paragraphs? Or is it necessary...
5
by: joelbyrd | last post by:
Didn't know exactly where to post this, but: How do I get line breaks in a textarea? I'm pulling text from a database, and this text definately has line breaks in it, because I replaced all the...
3
by: nashak | last post by:
Hello, In a Stored Proc, I am building a string variable. I am getting outputs from 4 different queries and would like the string to have line breaks to display each entry in a different line in...
6
by: Steve | last post by:
I'm getting a string such as name1\r\nname2 how can I remove the \r\n and just have the string as name1 name2?
0
by: alexpetrie | last post by:
I am using a form to enter data and I want to be able to add line breaks within a single field <shift><enter> or <control><enter> puts them into the form field and they seem to be stored in the...
9
by: Peter Hartlén | last post by:
I understand that the\n and \r only means something to the C# compiler so when retrieving a line like "Hello\r\nWorld" from a resource file (localized form or self made resource file), it prints...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.