Cut String
-
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
................
-
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
................
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 )
-
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
................
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
-
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
................
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
-
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
Thank you so much, i hope this helpful. Socheat
................
-
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
Thanks, i hope this helpful. Socheat
................
-
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 )
What is your answer? Socheat
................
-
What is your answer? Socheat
................
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 )
-
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 )