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. Split string

Split string

Scheduled Pinned Locked Moved C#
tutorial
5 Posts 3 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.
  • R Offline
    R Offline
    Rahul RK
    wrote on last edited by
    #1

    Hello Frieds, I just want to ask you that, How to split the string by another string. Take ex.- string tosplit = "10***3*2**5"; string delim = "***"; now o/p should be split1 = 10 split2 = 3*2**5 Thanks in Advance. Rahul Kulkarni.

    J D 2 Replies Last reply
    0
    • R Rahul RK

      Hello Frieds, I just want to ask you that, How to split the string by another string. Take ex.- string tosplit = "10***3*2**5"; string delim = "***"; now o/p should be split1 = 10 split2 = 3*2**5 Thanks in Advance. Rahul Kulkarni.

      J Offline
      J Offline
      jjansen
      wrote on last edited by
      #2

      Try this: string[] Parts = tosplit.Split("***", StringSplitOptions.RemoveEmptyEntries);

      R 1 Reply Last reply
      0
      • J jjansen

        Try this: string[] Parts = tosplit.Split("***", StringSplitOptions.RemoveEmptyEntries);

        R Offline
        R Offline
        Rahul RK
        wrote on last edited by
        #3

        Firstly Thanks for your response. You have suggested "StringSplitOptions". But i think it is not in the framework-1.1 Can you suggest any other solution. Rahul Kulkarni

        J 1 Reply Last reply
        0
        • R Rahul RK

          Firstly Thanks for your response. You have suggested "StringSplitOptions". But i think it is not in the framework-1.1 Can you suggest any other solution. Rahul Kulkarni

          J Offline
          J Offline
          jjansen
          wrote on last edited by
          #4

          RahulRKulkarni wrote:

          But i think it is not in the framework-1.1

          You're right, it's new in Framework 2.0. Perhaps you can use IndexOf("***") in combination with Substring.

          1 Reply Last reply
          0
          • R Rahul RK

            Hello Frieds, I just want to ask you that, How to split the string by another string. Take ex.- string tosplit = "10***3*2**5"; string delim = "***"; now o/p should be split1 = 10 split2 = 3*2**5 Thanks in Advance. Rahul Kulkarni.

            D Offline
            D Offline
            Dustin Metzgar
            wrote on last edited by
            #5

            Use a regular expression:

            Regex re = new Regex(@"\*\*\*");
            string[] splits = re.Split(tosplit);


            Logifusion[^] If not entertaining, write your Congressman.

            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