Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Removing "Back-Slash \" from string

Removing "Back-Slash \" from string

Scheduled Pinned Locked Moved C#
tutorial
8 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    M Riaz Bashir
    wrote on last edited by
    #1

    Hi, I want to remove "Back-Slashes \" from string. Kindly note the following example.

    string strText = "(0,2,\"\",\"113.07\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\")";

    Thank you

    L B D P W 5 Replies Last reply
    0
    • M M Riaz Bashir

      Hi, I want to remove "Back-Slashes \" from string. Kindly note the following example.

      string strText = "(0,2,\"\",\"113.07\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\")";

      Thank you

      L Offline
      L Offline
      loveangel888
      wrote on last edited by
      #2

      try the String replace method this is the MSDN for it

      M 1 Reply Last reply
      0
      • M M Riaz Bashir

        Hi, I want to remove "Back-Slashes \" from string. Kindly note the following example.

        string strText = "(0,2,\"\",\"113.07\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\")";

        Thank you

        B Offline
        B Offline
        Blue_Boy
        wrote on last edited by
        #3

        use Replace to do it

        string strText = "(0,2,\"\",\"113.07\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\")";
        strText = strText.Replace("\\","");


        I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.cacttus.com

        1 Reply Last reply
        0
        • L loveangel888

          try the String replace method this is the MSDN for it

          M Offline
          M Offline
          M Riaz Bashir
          wrote on last edited by
          #4

          I tried following method but it does'nt work.

          strText = strText.Replace('\',String.Empty);

          strText = strText.Replace(('\').ToString(),String.Empty);

          L 1 Reply Last reply
          0
          • M M Riaz Bashir

            I tried following method but it does'nt work.

            strText = strText.Replace('\',String.Empty);

            strText = strText.Replace(('\').ToString(),String.Empty);

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            You need to use the double backslash (single backslash in a string is the escape mark) and also use a String rather than character, thus:

            strText = strText.Replace(("\\"), String.Empty);

            See here[^] for full details.

            The best things in life are not things.

            1 Reply Last reply
            0
            • M M Riaz Bashir

              Hi, I want to remove "Back-Slashes \" from string. Kindly note the following example.

              string strText = "(0,2,\"\",\"113.07\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\")";

              Thank you

              D Offline
              D Offline
              David1987
              wrote on last edited by
              #6

              There are no backslashes in that string. \" is a quote.

              1 Reply Last reply
              0
              • M M Riaz Bashir

                Hi, I want to remove "Back-Slashes \" from string. Kindly note the following example.

                string strText = "(0,2,\"\",\"113.07\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\")";

                Thank you

                P Offline
                P Offline
                Prasanta_Prince
                wrote on last edited by
                #7

                Process is same what blueboy ellastrate.

                1 Reply Last reply
                0
                • M M Riaz Bashir

                  Hi, I want to remove "Back-Slashes \" from string. Kindly note the following example.

                  string strText = "(0,2,\"\",\"113.07\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\")";

                  Thank you

                  W Offline
                  W Offline
                  wizardzz
                  wrote on last edited by
                  #8

                  Are you sure you want to remove the \'s, they are actually what allows you string to contain the character: " You can't remove those because \" really means " in the string. If they were \\ it would mean \. So why are you trying to remove the characters that aren't even there?

                  Craigslist Troll: litaly@comcast.net "I have a theory that the truth is never told during the nine-to-five hours. " — Hunter S. Thompson

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups