remove new line characters

  • Thread starter Thread starter Steve
  • Start date Start date
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?
 
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?
 
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.
 
Either way, I would use the Regex.Split() method in
System.Text.RegularExpressions.
 
Hello Steve,

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

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

Jesse
 
Back
Top