字符的位置在串电流位置的左边 [英] Position of character to the left of current position in string
本文介绍了字符的位置在串电流位置的左边的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从字符串中的我需要找到一个字符到我位置左侧的最近位置的一些任意位置。如果我想执行此操作的权利,我可以只使用.IndexOf,但如何做给我不确定左侧。
From some arbitrary position in a string I need to find the closest position of a character to the left of my position. If I was wanting to perform this operation to the right I could just use .IndexOf, but how to do it to the left I am unsure.
我来到了刚刚递减循环开始我的立场,或将反向字符串,并使用普通.IndexOf
The two ways I came up with were just a decrementing loop starting at my position or, putting the string in reverse and using a normal .IndexOf
任何人有acheiving这个什么更好的办法
Anyone else have any better ways of acheiving this?
推荐答案
怎么样?
yourstring.LastIndexOf("foo", 0, currentPosition)
这篇关于字符的位置在串电流位置的左边的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文