将字符串分割到去年分离器 [英] Split string by last separator

查看:148
本文介绍了将字符串分割到去年分离器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经是一个包含了一堆由分割字符串的巨型文本文件\ 。对我来说,问题是可以有5 \ 或4 \ 或3 \\ \\



我要拉最后 \ 无论怎么什么许多人也有。 。任何帮助表示赞赏。



例如:

 
I\\\
eed\这种
I\want\line\this
Hello\give\me\all\this

我所需要的单词这个为例,但显然它不只是字这个


解决方案

 字符串最后= inputString.Substring(inputString.LastIndexOf('\\')+ 1); 


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 \.

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.

解决方案

string last = inputString.Substring(inputString.LastIndexOf('\\') + 1);

这篇关于将字符串分割到去年分离器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆