remove new line characters

Discussion in 'ASP .Net' started by Steve, Aug 3, 2007.

  1. Steve

    Steve Guest

    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, Aug 3, 2007
    #1
    1. Advertising

  2. Steve

    Fred Chateau Guest

    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

    "Steve" <> wrote in message
    news:...
    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, Aug 3, 2007
    #2
    1. Advertising

  3. Steve

    Steve Guest

    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.
    "Fred Chateau" <fchateau@127.0.0.1> wrote in message
    news:...
    > 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
    >
    > "Steve" <> wrote in message
    > news:...
    > 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, Aug 3, 2007
    #3
  4. Steve

    Fred Chateau Guest

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

    --
    Regards,

    Fred Chateau
    fchateauAtComcastDotNet


    "Steve" <> wrote in message
    news:eE%...
    > 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.
    > "Fred Chateau" <fchateau@127.0.0.1> wrote in message
    > news:...
    >> 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
    >>
    >> "Steve" <> wrote in message
    >> news:...
    >> 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, Aug 3, 2007
    #4
  5. 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
    > 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.
    > "Fred Chateau" <fchateau@127.0.0.1> wrote in message
    > news:...
    >> 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
    >> "Steve" <> wrote in message
    >> news:...
    >> 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
     
    Jesse Houwing, Aug 3, 2007
    #5
  6. Steve

    Steve Guest

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

    do you have an example?

    "Fred Chateau" <fchateau@127.0.0.1> wrote in message
    news:...
    > Either way, I would use the Regex.Split() method in
    > System.Text.RegularExpressions.
    >
    > --
    > Regards,
    >
    > Fred Chateau
    > fchateauAtComcastDotNet
    >
    >
    > "Steve" <> wrote in message
    > news:eE%...
    >> 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.
    >> "Fred Chateau" <fchateau@127.0.0.1> wrote in message
    >> news:...
    >>> 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
    >>>
    >>> "Steve" <> wrote in message
    >>> news:...
    >>> 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, Aug 3, 2007
    #6
  7. Alexey Smirnov, Aug 3, 2007
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hugo
    Replies:
    10
    Views:
    1,324
    Matt Humphrey
    Oct 18, 2004
  2. Radovan Garabik

    Re: remove special characters from line

    Radovan Garabik, Jul 1, 2003, in forum: Python
    Replies:
    0
    Views:
    679
    Radovan Garabik
    Jul 1, 2003
  3. Egor Bolonev

    Re: remove special characters from line

    Egor Bolonev, Jul 1, 2003, in forum: Python
    Replies:
    2
    Views:
    542
    Chris Rennert
    Jul 1, 2003
  4. kaushikshome
    Replies:
    4
    Views:
    778
    kaushikshome
    Sep 10, 2006
  5. rvino
    Replies:
    0
    Views:
    4,662
    rvino
    Aug 14, 2007
Loading...

Share This Page