Dovberman
asked on
Find last occurance of a substring within a string
I have the following string: which begins after the last '//':
"abc//def//hij//I am the owner"
I need to return "I am the owner" which always begins after the last '//':
The length of the final substring can vary.
What is the best way to do this?
Thanks
"abc//def//hij//I am the owner"
I need to return "I am the owner" which always begins after the last '//':
The length of the final substring can vary.
What is the best way to do this?
Thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Dim myString As String = "abc//def//hij//I am the owner"
Dim arr As String()
arr = myString.Split(CChar("//")
messagebox.show(arr(arr.Length).ToString
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry, this should work:
Dim myString As String = "abc//def//hij//I am the owner"
Dim arr As String()
myString.Replace("//", "#")
arr = myString.Split(CChar("#"))
MessageBox.Show(arr(arr.Length)).ToString()
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
No close, @Number-1 posted link to the answer.
Accept this one.
https://www.experts-exchange.com/questions/27983783/Find-last-occurance-of-a-substring-within-a-string.html?anchorAnswerId=38740784#a38740784
Accept this one.
https://www.experts-exchange.com/questions/27983783/Find-last-occurance-of-a-substring-within-a-string.html?anchorAnswerId=38740784#a38740784
See last comment
ASKER
Thanks for all the responses. These gave me hints for working out a solution.
Open in new window