remove new line characters

S

Steve

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?
 
F

Fred Chateau

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
fchateauAtComcastDotNet

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?
 
S

Steve

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,name3,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.
 
F

Fred Chateau

Either way, I would use the Regex.Split() method in
System.Text.RegularExpressions.
 
J

Jesse Houwing

Hello Steve,

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

string[] names = inputString.Split(new char[]{',','\r','\n'}, StringSplitOptions.RemoveEmptyEntries)

Jesse
 
S

Steve

OK, I'll have to take a look at that due to I never used it.

do you have an example?
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top