我用winForm做了个,你看下代码吧:
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string richString = richTextBox1.Text;
string[] richArrayString = richString.Split(' ');
int count = 1;
foreach (string rstr in richArrayString)
{
if (rstr == "fmov" || rstr == "E:\\yoli" || rstr == "E:\\test")
{
string searchString = String.Format("找到的第{0}个相关字符串为:", count) + rstr;
listBox1.Items.Add(searchString);
count++;
}
}
}
private void button2_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
}
}
}
这是程序运行的效果,在右边的listbox显示找到的匹配项!
string s = "fmov E:\yoli E:\test";
s.split(' ');