find a value after the character

  • Thread starter Thread starter DaveF
  • Start date Start date
Hi Tim,

I did/do this also often, but the substring is overloaded.
The lenght is not necessary when it is thru the end.

Dim newString As String = mystring.Substring(mystring.LastIndexOf("/")+1)

Just as addition, nothing wrong with your solution.

Cor
 
DaveF,
In addition to the other comments.

If you are parsing (file system) Paths I would recommend the functions in
System.IO.Path, such as:

Dim fullPath As String = "www.ssss.com/images/theimage.jpg"
Dim fileName As String = System.IO.Path.GetFileName(fullPath)

If you are parsing URLs I would recommend the System.Uri class, such as:

Dim fullPath As String = "http://www.ssss.com/images/theimage.jpg?x=1"
Dim uri As New System.Uri(fullPath)
Dim fileName As String = System.IO.Path.GetFileName(uri.AbsolutePath)

Hope this helps
Jay
 
Back
Top