given any string, i want to remove any letters after a specific character.
this character may exist multiple times in the string and i only want to apply this to the last occurrance.
so lets say "/" is the character, here are some examples:
http://www.ibm.com/test ==> http://www.ibm.com
hello/test ==> hello
Another options is to use String.Remove
With some error checking the code can be extracted to an extension method like:
It could be used like:
Output:
or
(edited to cover the case when '/' does not exist in the string, as mentioned in comments)