Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / August 2007

Tip: Looking for answers? Try searching our database.

remove new line characters

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steve - 03 Aug 2007 18:09 GMT
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?
Fred Chateau - 03 Aug 2007 18:22 GMT
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?

Signature

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?
Steve - 03 Aug 2007 18:29 GMT
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.
> If you remove the new line characters. you're not going to get:
>
[quoted text clipped - 15 lines]
> name1
> name2?
Fred Chateau - 03 Aug 2007 18:40 GMT
Either way, I would use the Regex.Split() method in
System.Text.RegularExpressions.

Signature

Regards,

Fred Chateau
fchateauAtComcastDotNet

> well,
> the thing is I need to pass each name into a method so I can get their
[quoted text clipped - 36 lines]
>> name1
>> name2?
Steve - 03 Aug 2007 18:46 GMT
OK, I'll have to take a look at that due to I never used it.

do you have an example?

> Either way, I would use the Regex.Split() method in
> System.Text.RegularExpressions.
[quoted text clipped - 39 lines]
>>> name1
>>> name2?
Alexey Smirnov - 03 Aug 2007 23:46 GMT
> 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(input,"\r\n"))
{
other_method(s);
}

More about Regex.Split
http://msdn2.microsoft.com/en-us/library/system.text.regularexpressions.regex.sp
lit.aspx


Hope this helps
Jesse Houwing - 03 Aug 2007 18:45 GMT
Hello Steve,

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

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

Jesse

> well,
> the thing is I need to pass each name into a method so I can get their
[quoted text clipped - 36 lines]
>> name1
>> name2

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.