从匹配单词c#中删除字符串 [英] Remove string from match word c#

查看:97
本文介绍了从匹配单词c#中删除字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从匹配单词C中删除字符串#



for ex



string test =删除字符串匹配单词.......;



如果单词是来自然后从中删除字符串所有字符串删除其余的

解决方案

试试这个

  string  test =  从匹配字中删除字符串.......< /跨度>; 
int index1 = test.IndexOf( );
if (index1!= -1)
{
string result2 = test.Remove(index1);
}
其他
{
// < span class =code-comment>fromnot found

}


string test =从匹配字中删除字符串.......;



//首先我们得到指数



int index = test.indexof(from);



test = test.substring(0,index)


< pre lang =cs> string test = 删除来自匹配词的字符串.......;
int index = test.IndexOf( );
int l = test.Length;
test = test.Substring(index + 4);


Remove string from match word C#

for ex

string test="Remove string from match word.......";

if word is "from" then Remove string from " all string remove rest of all "

解决方案

Try this

string test="Remove string from match word.......";
int index1 = test.IndexOf("from");
if (index1 != -1)
{
    string result2 = test.Remove(index1);
}
else
{
  // "from" not found
}


string test="Remove string from match word.......";

// first we get the index of from

int index = test.indexof("from");

test = test.substring(0,index)


string test = "Remove string from match word.......";
      int index = test.IndexOf("from");
      int l = test.Length;
      test = test.Substring(index+4);


这篇关于从匹配单词c#中删除字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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