从字符串中删除文本,直到达到特定字符为止 [英] Remove text from string until it reaches a certain character
本文介绍了从字符串中删除文本,直到达到特定字符为止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在尝试解决此问题时遇到问题.我需要修复"一些链接,这是一个示例:
I'm having a issue trying to figure out this. I need to "fix" some links, here is an example:
- www.site.com/link/index.php?REMOVETHISHERE
- www.site.com/index.php?REMOVETHISHERE
所以基本上我想删除所有东西,直到达到?特点.感谢您的帮助.
So basically I want to remove everything till it reaches the ? character. Thanks for your help.
推荐答案
string s = @"www.site.com/link/index.php?REMOVETHISHERE";
s = s.Remove( s.LastIndexOf('?') );
//Now s will be simply "www.site.com/link/index.php"
应该做
这篇关于从字符串中删除文本,直到达到特定字符为止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文