从开头修剪字符串到子字符串c#
我在切断绳子时遇到了麻烦。我有一个接收传入数据的 Windows 窗体应用程序。到目前为止我找到的例子都是使用char来定位的。我需要让它搜索整个 "*S"
而不仅仅是其中的一个字符。
我确实找到了一种方法来获取刺痛的索引,并从该点修剪到末尾(sting.remove)。
我的问题是我需要修剪开头。所以修剪索引方法可以工作,但我还没有找到如何做到这一点。
我拥有的是一堆数据,例如
"ok \r\n *S 38773 get 3042"
我需要做的是找到 *S 并删除从开头到 *S
的所有内容。因为返回并不总是相同,所以我无法使用替换或删除方法。我无法预测 *S 之前会发生什么,其余数据是动态的。
任何关于如何从本质上修剪“*S”开始的例子都会很棒。谢谢。
I am having trouble cutting down my string. I have a windows form application that receives incoming data. So far the examples I have found all use char to locate. I need to have it search for the entire "*S"
and not just one character of it.
I did find a way to get the index of the sting and trim from that point to the end (sting.remove).
My problem is i need to trim the beginning. so a trim to index method would work but I haven't found how to do that.
What i have is a bunch of data like
"ok \r\n *S 38773 get 3042"
What I need to do is locate the *S and remove everything from the beginning to the *S
. Because the return is not always the same I cant use replace or remove methods. I cant predict what will come before the *S and the remaining data is dynamic.
Any examples on how to essentially trim start to the "*S" would be wonderful. Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)