473,569 Members | 2,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

remove new line characters

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?
Aug 3 '07 #1
6 2989
If you remove the new line characters. you're not going to get:

name1
name2

You'll get:

name1 name2

Is that what you want?

--
Regards,

Fred Chateau
fchateauAtComca stDotNet

"Steve" <St***@communit y.nospam.comwro te in message
news:ev******** ******@TK2MSFTN GP04.phx.gbl...
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?
Aug 3 '07 #2
well,
the thing is I need to pass each name into a method so I can get their
information.

here is what I have.

I have a textbox that a user can enter names in, its a multiline textbox and
they can enter the names in 2 ways,

1) all on one line and let the textbox wrap them
-- name1,name2,nam e3,name4,name5,
name6 and so on

2) or like this
name1
name2
name3
and so on

if they enter like #2 I need to take each name one by one and get their
information.
"Fred Chateau" <fc******@127.0 .0.1wrote in message
news:uG******** ******@TK2MSFTN GP02.phx.gbl...
If you remove the new line characters. you're not going to get:

name1
name2

You'll get:

name1 name2

Is that what you want?

--
Regards,

Fred Chateau
fchateauAtComca stDotNet

"Steve" <St***@communit y.nospam.comwro te in message
news:ev******** ******@TK2MSFTN GP04.phx.gbl...
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?

Aug 3 '07 #3
Either way, I would use the Regex.Split() method in
System.Text.Reg ularExpressions .

--
Regards,

Fred Chateau
fchateauAtComca stDotNet
"Steve" <St***@communit y.nospam.comwro te in message
news:eE******** ********@TK2MSF TNGP02.phx.gbl. ..
well,
the thing is I need to pass each name into a method so I can get their
information.

here is what I have.

I have a textbox that a user can enter names in, its a multiline textbox
and they can enter the names in 2 ways,

1) all on one line and let the textbox wrap them
-- name1,name2,nam e3,name4,name5,
name6 and so on

2) or like this
name1
name2
name3
and so on

if they enter like #2 I need to take each name one by one and get their
information.
"Fred Chateau" <fc******@127.0 .0.1wrote in message
news:uG******** ******@TK2MSFTN GP02.phx.gbl...
>If you remove the new line characters. you're not going to get:

name1
name2

You'll get:

name1 name2

Is that what you want?

--
Regards,

Fred Chateau
fchateauAtComc astDotNet

"Steve" <St***@communit y.nospam.comwro te in message
news:ev******* *******@TK2MSFT NGP04.phx.gbl.. .
I'm getting a string such as

name1\r\nnam e2

how can I remove the \r\n and just have the string as

name1
name2?


Aug 3 '07 #4
Hello Steve,

You can use the split function of Strign to do this.

string[] names = inputString.Spl it(new char[]{',','\r','\n'} , StringSplitOpti ons.RemoveEmpty Entries)

Jesse
well,
the thing is I need to pass each name into a method so I can get their
information.
here is what I have.

I have a textbox that a user can enter names in, its a multiline
textbox and they can enter the names in 2 ways,

1) all on one line and let the textbox wrap them
-- name1,name2,nam e3,name4,name5,
name6 and so on
2) or like this
name1
name2
name3
and so on
if they enter like #2 I need to take each name one by one and get
their
information.
"Fred Chateau" <fc******@127.0 .0.1wrote in message
news:uG******** ******@TK2MSFTN GP02.phx.gbl...
>If you remove the new line characters. you're not going to get:

name1
name2
You'll get:

name1 name2

Is that what you want?

-- Regards,

Fred Chateau
fchateauAtComc astDotNet
"Steve" <St***@communit y.nospam.comwro te in message
news:ev******* *******@TK2MSFT NGP04.phx.gbl.. .
I'm getting a string such as
name1\r\nnam e2

how can I remove the \r\n and just have the string as

name1
name2?

Aug 3 '07 #5
OK, I'll have to take a look at that due to I never used it.

do you have an example?

"Fred Chateau" <fc******@127.0 .0.1wrote in message
news:O5******** ******@TK2MSFTN GP02.phx.gbl...
Either way, I would use the Regex.Split() method in
System.Text.Reg ularExpressions .

--
Regards,

Fred Chateau
fchateauAtComca stDotNet
"Steve" <St***@communit y.nospam.comwro te in message
news:eE******** ********@TK2MSF TNGP02.phx.gbl. ..
>well,
the thing is I need to pass each name into a method so I can get their
information.

here is what I have.

I have a textbox that a user can enter names in, its a multiline textbox
and they can enter the names in 2 ways,

1) all on one line and let the textbox wrap them
-- name1,name2,nam e3,name4,name5,
name6 and so on

2) or like this
name1
name2
name3
and so on

if they enter like #2 I need to take each name one by one and get their
information.
"Fred Chateau" <fc******@127.0 .0.1wrote in message
news:uG******* *******@TK2MSFT NGP02.phx.gbl.. .
>>If you remove the new line characters. you're not going to get:

name1
name2

You'll get:

name1 name2

Is that what you want?

--
Regards,

Fred Chateau
fchateauAtCom castDotNet

"Steve" <St***@communit y.nospam.comwro te in message
news:ev****** ********@TK2MSF TNGP04.phx.gbl. ..
I'm getting a string such as

name1\r\nname 2

how can I remove the \r\n and just have the string as

name1
name2?



Aug 3 '07 #6
On Aug 3, 7:46 pm, "Steve" <St...@communit y.nospam.comwro te:
OK, I'll have to take a look at that due to I never used it.

do you have an example?
string input = "name1\r\nname2 ";
foreach(string s in Regex.Split(inp ut,"\r\n"))
{
other_method(s) ;
}

More about Regex.Split
http://msdn2.microsoft.com/en-us/lib...gex.split.aspx

Hope this helps

Aug 3 '07 #7

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

Similar topics

7
3060
by: RiGGa | last post by:
Hi, I have a html file that I need to process and it contains text in this format: <TD><SPAN class=xf id=EmployeeNo title="Employee Number">0123456</SPAN></TD></TR> (Note split over two lines is as it appears in the source file.)
11
9453
by: James Hu | last post by:
This program is long. I don't really want to bore everyone with the details, but it handles wierd cases like: /\ * this is a comment *\ / #define FOO ??/* this is not a comment */ char *a = /* this is a comment "\*/"this is a string"/*" another comment */;
2
9447
by: collinm | last post by:
hi here my code FILE *fp; char *line; #define LINE_MAX 30 fp = fopen("test1.txt", "r");
4
2564
by: kaushikshome | last post by:
Can anyone please help me in writing the code in C++ : I want a read a file line by line,remove the lines which have length of a particular field in a line exceeding 63 characters After removing the line the corresponding blank spaces generated after removal of the line also needs to be removed. .. I am in urgent need for this...
100
5066
by: jacob navia | last post by:
Recently, a heated debate started because of poor mr heathfield was unable to compile a program with // comments. Here is a utility for him, so that he can (at last) compile my programs :-) More seriously, this code takes 560 bytes. Amazing isn't it? C is very ompact, you can do great things in a few bytes. Obviously I have avoided...
9
5673
by: Frank Potter | last post by:
I only want to remove the comments which begin with "//". I did like this, but it doesn't work. r=re.compile(ur"//+$", re.UNICODE|re.VERBOSE) f=file.open("mycpp.cpp","r") f=unicode(f,"utf8") r.sub(ur"",f) Will somebody show me the right way? Thanks~~
3
4039
by: afr02hrs | last post by:
Hi Experts I am trying to get the following program running correctly. I would like to be able to input a line of text containing multiple space characters between words and have the program remove any number of excess space characters so that the sentence is rewritten correctly containing only 1 space character between individual words. ...
5
30913
by: LEM | last post by:
Hi, I'm trying to remove any empty lines from a string, and I am doing the following: String pp; pp = "\r\n\r\n1\r\n23\r\n\r\n4"; pp = pp.Replace("\r\n\r\n", "\r\n");
0
3199
by: coco09 | last post by:
Hi all I have the following line of text in my script $var = do {local $/; <$FILE>};#<-- slurp whole file in scalar The problem i am having is that the input file is a pcl file and has new line characters in the middle of a line. When the perl script is evaluating each line it meets this new line character and outputs it onto a new line...
0
7618
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7926
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6287
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5223
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2117
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1228
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.