过滤两个特殊字符之间的文本

wou*_*ter 1 .net c# string split

例如,我有这些字符串:

"qwe/qwe/qwe/qwe//qwe/somethinghere_blabla.exe"
"qwe/qwe/q//we/qwe//qwe/somethingother_here_blabla.exe"
"qwe/qwe/qwe/qwe//qwe/some_numbers_here_blabla.exe"
Run Code Online (Sandbox Code Playgroud)

现在我想在最后的'/'和最后的'_'之间得到文本.结果将是:

"somethinghere"
"somethingother_here"
"some_numbers_here"
Run Code Online (Sandbox Code Playgroud)

最简单,最清晰的方法是什么?

我不知道如何做到这一点,如果我将它们分成'/'和'_',那么这样做会分开吗?我想不出怎么办.

也许从末尾扫描字符串直到它到达第一个'/'和'_'?或者有更简单快捷的方式吗?因为它必须扫描~10,000个字符串.

string[] words = line.Split('/', '_'); //maybe use this? probably not
Run Code Online (Sandbox Code Playgroud)

提前致谢!

ASh*_*ASh 9

string s = "qwe/qwe/q//we/qwe//qwe/somethingother_here_blabla.exe";
int last_ = s.LastIndexOf('_');
if (last_ < 0) // _ not found, take the tail of string
    last_ = s.Length;
int lastSlash = s.LastIndexOf('/');
string part = s.Substring(lastSlash + 1, last_ - lastSlash - 1);
Run Code Online (Sandbox Code Playgroud)