Remove newline charcters froma string

Discussion in 'ASP .Net' started by peelman, Oct 18, 2005.

  1. peelman

    peelman Guest

    For some reason this is not working for me. How to remove all newline
    characters from a string? I have tried:

    myString.Replace ("\n", "");

    I have also tried using TrimStart and TrimEnd methods from String
    (using a char array with a '\n' in it), but to no avail.

    Has it to do with the '\r' somewhere in there, or is there just an
    easier way to this? I know this should not be hard.

    Thanks in advance,

    NC
     
    peelman, Oct 18, 2005
    #1
    1. Advertising

  2. peelman

    Karl Seguin Guest

    myString = myString.Replace(System.Environment.NewLine, "");

    Karl

    P.S. - yes, it probably have something to do with \r

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/
    "peelman" <> wrote in message
    news:...
    > For some reason this is not working for me. How to remove all newline
    > characters from a string? I have tried:
    >
    > myString.Replace ("\n", "");
    >
    > I have also tried using TrimStart and TrimEnd methods from String
    > (using a char array with a '\n' in it), but to no avail.
    >
    > Has it to do with the '\r' somewhere in there, or is there just an
    > easier way to this? I know this should not be hard.
    >
    > Thanks in advance,
    >
    > NC
    >
     
    Karl Seguin, Oct 18, 2005
    #2
    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. Chris Kettenbach

    Remove unwanted charcters from a string

    Chris Kettenbach, Jul 20, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    479
    Chris Kettenbach
    Jul 20, 2005
  2. brandons of mass destruction

    charcters styles via html

    brandons of mass destruction, Jul 26, 2003, in forum: XML
    Replies:
    1
    Views:
    440
    Steven Dilley
    Jul 30, 2003
  3. ABHIJIT B

    ASP.NET 2.0 TextBOx WildCard charcters

    ABHIJIT B, Feb 20, 2008, in forum: ASP .Net
    Replies:
    0
    Views:
    401
    ABHIJIT B
    Feb 20, 2008
  4. Joel Goldstick
    Replies:
    1
    Views:
    93
    alex23
    Jul 2, 2013
  5. Dave Angel
    Replies:
    2
    Views:
    104
    Dave Angel
    Jul 2, 2013
Loading...

Share This Page