Reputation: 23
I am reading in a few file names that have the same basic title but have #n
at the end, where n
is some number. For example, Sony#1
, Salmon#2
, Cats#3
, etc. I want to strip the #n
from the end of the file name, so Sony#1
would become Sony
and so on. How can I achieve this?
Upvotes: 0
Views: 110
Reputation: 1402
Dim fileName as String = "Sony#1"
Dim fileKeyword as String = Split(fileName, "#")(0) ' Sony
Upvotes: 1
Reputation: 9888
If the number is always preceded by #
then you can try this:
Dim str As String '= "Name#3"
Dim sCat As String = str.Substring(0, str.LastIndexOf("#"c))
Upvotes: 1