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. Visual Basic
  4. split "C:\hello" "C:\h\ddd"

split "C:\hello" "C:\h\ddd"

Scheduled Pinned Locked Moved Visual Basic
data-structuresquestion
6 Posts 5 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    when you have string "C:\my fodler\hello" "C:\Documents and Settings\admin\" is given, how can I use the function split to separate this string and convert into an array. "C:\my fodler\hello" "C:\Documents and Settings\admin\" I have try with Chr$(22) which is the space btwn double quotation, but seemslike it can't find the space btwn. Also I have to be aware of those space for path"My Folder". Probably easy for others. Thanks Shin

    A D S D 4 Replies Last reply
    0
    • L Lost User

      when you have string "C:\my fodler\hello" "C:\Documents and Settings\admin\" is given, how can I use the function split to separate this string and convert into an array. "C:\my fodler\hello" "C:\Documents and Settings\admin\" I have try with Chr$(22) which is the space btwn double quotation, but seemslike it can't find the space btwn. Also I have to be aware of those space for path"My Folder". Probably easy for others. Thanks Shin

      A Offline
      A Offline
      Andy M
      wrote on last edited by
      #2

      ASCII code 22 is not the space character, the space character is 32.

      1 Reply Last reply
      0
      • L Lost User

        when you have string "C:\my fodler\hello" "C:\Documents and Settings\admin\" is given, how can I use the function split to separate this string and convert into an array. "C:\my fodler\hello" "C:\Documents and Settings\admin\" I have try with Chr$(22) which is the space btwn double quotation, but seemslike it can't find the space btwn. Also I have to be aware of those space for path"My Folder". Probably easy for others. Thanks Shin

        D Offline
        D Offline
        Dave Kreskowiak
        wrote on last edited by
        #3

        32 is the space character, not 22. The problem your going to have is that splitting on the space will also split on any spaces in the path names. Your string "C:\my fodler\hello" "C:\Documents and Settings\admin\", I'm assuming your including the quotes in the string!, will split liek this:

        "C:\\my
        folder\\hello"
        "C:\\Documents
        and
        Settings
        

        You will have to supply your own function to parse this string. Assuming your including the quotes in the string as above, you can split the string on the " character instead. Then look through the resulting array and remove the blank array items. This should give you the paths your looking for. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

        1 Reply Last reply
        0
        • L Lost User

          when you have string "C:\my fodler\hello" "C:\Documents and Settings\admin\" is given, how can I use the function split to separate this string and convert into an array. "C:\my fodler\hello" "C:\Documents and Settings\admin\" I have try with Chr$(22) which is the space btwn double quotation, but seemslike it can't find the space btwn. Also I have to be aware of those space for path"My Folder". Probably easy for others. Thanks Shin

          S Offline
          S Offline
          Spanky3
          wrote on last edited by
          #4

          char [] charArray = string.split("\"") should do the trick you should end up with 3 parts 1 = " 2 = the dir path 3 = "

          D 1 Reply Last reply
          0
          • S Spanky3

            char [] charArray = string.split("\"") should do the trick you should end up with 3 parts 1 = " 2 = the dir path 3 = "

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #5

            Nope. Using the original string he put in his first post and splitting on a backslash, he'd end up with

            str = """C:\my fodler\hello"" ""C:\Documents and Settings\admin\"""
            Dim charArray() = str.Split("\")

            0 = "C:
            1 = my fodler
            2 = hello" "C:
            3 = Documents and Settings
            4 = admin
            5 = "

            RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

            1 Reply Last reply
            0
            • L Lost User

              when you have string "C:\my fodler\hello" "C:\Documents and Settings\admin\" is given, how can I use the function split to separate this string and convert into an array. "C:\my fodler\hello" "C:\Documents and Settings\admin\" I have try with Chr$(22) which is the space btwn double quotation, but seemslike it can't find the space btwn. Also I have to be aware of those space for path"My Folder". Probably easy for others. Thanks Shin

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

              You might want to try either of these methods: 1. Using Regular Expressions Dim s As Regex = New Regex("\""([^\""]*)\""(?:\s)*") Dim match As Match = s.Match(w) ' where w is the string mentioned While (match.Success) ' match.Groups(1).Value will contain the string match = match.NextMatch() End While 2. Since filenames can't contain strings, you can replace " " sequence with a single character, trim the quotation marks at the beginning and end of the string, and use the Split function, as follows (assume w is the string that holds the folder names): Const quotchar As String = """" w = w.Trim(quotchar) ' remove quotes from start and end w = w.Replace(""" """, quotchar) ' replace " " with " Dim stringarray As String() = w.Split(quotchar) ' Now just invoke split and save to array Hope this helps. :)

              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