[英]Split string by last separator
What I have is a giant text file that contains a bunch of strings that are split by \\
. 我所拥有的是一个巨大的文本文件,其中包含一串由\\
分割的字符串。 The problem for me is there can be 5 \\
or 4 \\
or 3 \\
. 对我来说问题是可以有5 \\
或4 \\
或3 \\
。
What I need to to pull the last \\
no matter how many of them there are. 无论有多少人,我需要把它拉到最后\\
。 Any help is appreciated. 任何帮助表示赞赏。
Examples: 例子:
I\need\this I\want\line\this Hello\give\me\all\this
I need the word this
for example, but obviously it's not just the word this
. 我所需要的单词this
的例子,但显然它不只是单词this
。
string last = inputString.Substring(inputString.LastIndexOf('\\') + 1);
string myString = inputString.Split('\\').Last();
差点忘了这个(尽管有点厚脸皮):
string result = Path.GetFilename(input);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.