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. Cut String

Cut String

Scheduled Pinned Locked Moved Visual Basic
helpcom
9 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.
  • S Offline
    S Offline
    Socheat Net
    wrote on last edited by
    #1

    Hi, I have problem this one Dim url As String="http://www.codeproject.com/" dim str As string str= url.Remove(0,7) I got the string "www.codeproject.com/" after i want to cut string "/" so it will be "www.codeproject.com". But when the url like this "http://www.codeproject.com/about.asp" I want to get result like this "www.codeproject.com" only please help me. Socheat

    ................

    C H K 3 Replies Last reply
    0
    • S Socheat Net

      Hi, I have problem this one Dim url As String="http://www.codeproject.com/" dim str As string str= url.Remove(0,7) I got the string "www.codeproject.com/" after i want to cut string "/" so it will be "www.codeproject.com". But when the url like this "http://www.codeproject.com/about.asp" I want to get result like this "www.codeproject.com" only please help me. Socheat

      ................

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Sounds like you want to either use the built in class that knows how to parse a URL, or use the Split method on the string class, splitting on the / and then grabbing the section you want.

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      S G 2 Replies Last reply
      0
      • S Socheat Net

        Hi, I have problem this one Dim url As String="http://www.codeproject.com/" dim str As string str= url.Remove(0,7) I got the string "www.codeproject.com/" after i want to cut string "/" so it will be "www.codeproject.com". But when the url like this "http://www.codeproject.com/about.asp" I want to get result like this "www.codeproject.com" only please help me. Socheat

        ................

        H Offline
        H Offline
        Harini N K
        wrote on last edited by
        #3

        Hi Check this code string strURL = "http://www.yahoo.com/quick/a.asp"; string strURLremove = strURL.Remove(0,7); if (strURLremove.IndexOf("/") > 0) { **strURLremove = strURLremove.Remove(strURLremove.IndexOf("/"), (strURLremove.Length - strURLremove.IndexOf("/")));** } Response.Write(" " + strURLremove.ToString()); Read the code in bold font carefully. Hope you are clear with this.

        Harini

        S 1 Reply Last reply
        0
        • S Socheat Net

          Hi, I have problem this one Dim url As String="http://www.codeproject.com/" dim str As string str= url.Remove(0,7) I got the string "www.codeproject.com/" after i want to cut string "/" so it will be "www.codeproject.com". But when the url like this "http://www.codeproject.com/about.asp" I want to get result like this "www.codeproject.com" only please help me. Socheat

          ................

          K Offline
          K Offline
          koolprasad2003
          wrote on last edited by
          #4

          hi Socheat i think u have to use Split() function and the saparator should be "/" like this, dim szStr as string= "http://www.codeproject.com/about.asp" Dim szArr as string() szArr = Split(szStr,"/",-1) in szArr(BLABLA) U should get the string like "www.codeproject.com" Hope it helps. Regards, koolprasad2003:)

          If the message is useful for U then please Rate This message... Be a good listener...Because Opprtunity knoughts softly...N-Joy

          S 1 Reply Last reply
          0
          • H Harini N K

            Hi Check this code string strURL = "http://www.yahoo.com/quick/a.asp"; string strURLremove = strURL.Remove(0,7); if (strURLremove.IndexOf("/") > 0) { **strURLremove = strURLremove.Remove(strURLremove.IndexOf("/"), (strURLremove.Length - strURLremove.IndexOf("/")));** } Response.Write(" " + strURLremove.ToString()); Read the code in bold font carefully. Hope you are clear with this.

            Harini

            S Offline
            S Offline
            Socheat Net
            wrote on last edited by
            #5

            Thank you so much, i hope this helpful. Socheat

            ................

            1 Reply Last reply
            0
            • K koolprasad2003

              hi Socheat i think u have to use Split() function and the saparator should be "/" like this, dim szStr as string= "http://www.codeproject.com/about.asp" Dim szArr as string() szArr = Split(szStr,"/",-1) in szArr(BLABLA) U should get the string like "www.codeproject.com" Hope it helps. Regards, koolprasad2003:)

              If the message is useful for U then please Rate This message... Be a good listener...Because Opprtunity knoughts softly...N-Joy

              S Offline
              S Offline
              Socheat Net
              wrote on last edited by
              #6

              Thanks, i hope this helpful. Socheat

              ................

              1 Reply Last reply
              0
              • C Christian Graus

                Sounds like you want to either use the built in class that knows how to parse a URL, or use the Split method on the string class, splitting on the / and then grabbing the section you want.

                Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                S Offline
                S Offline
                Socheat Net
                wrote on last edited by
                #7

                What is your answer? Socheat

                ................

                C 1 Reply Last reply
                0
                • S Socheat Net

                  What is your answer? Socheat

                  ................

                  C Offline
                  C Offline
                  Christian Graus
                  wrote on last edited by
                  #8

                  If you use the split method of the string class on the URL, you will get a string array and one of those elements will be www.codeproject.com, if you split on the /

                  Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                  1 Reply Last reply
                  0
                  • C Christian Graus

                    Sounds like you want to either use the built in class that knows how to parse a URL, or use the Split method on the string class, splitting on the / and then grabbing the section you want.

                    Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                    G Offline
                    G Offline
                    ganti r
                    wrote on last edited by
                    #9

                    Hi Socheat, you can either use a regex or simply use split method with /. If this is all you want accomplish, I will go with split.

                    rAm i Think, i Wait, i Fast -- Siddartha

                    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