-5
我有这样的功能:如何找到字符串中的C#的所有单词
public static string getBetween(string strSource, string strStart, string strEnd)
{
int Start, End;
if (strSource.Contains(strStart) && strSource.Contains(strEnd))
{
Start = strSource.IndexOf(strStart, 0) + strStart.Length;
End = strSource.IndexOf(strEnd, Start);
return strSource.Substring(Start, End - Start);
}
else
{
return "";
}
}
private void button9_Click(object sender, EventArgs e)
{
string text = "This is an example string and my data1 is here and my data2 is and my data3 is ";
richtTextBox1.Text = getBetween(text, "my", "is");
}
功能给了我这样的结果:
我想这样的结果:
data1 data2 data3
发布的所有字符串的样品** strSource,strStart,strEnd ** – rashfmnb
请勿张贴您的代码/链接屏幕截图,而是用您的问题发布实际的代码。 – Habib