我需要比较两个字符串,
比如
字符串1:“对比字符串”
以字符串1为基准,下面的都符合,判断下面的字符串包含多少字符串1,即字符串2:    “对比字符串 ”       //完全包括
字符串3:“我要对比字符串 ”       //全包括
字符串4:        “字符串我要 ”   //包括3个
字符串5:“我要对比”              //包括2个
字符串6:“串符字比对”            //不包括,因为连续字符至少有2个符合。
字符串7:“对比adfasf符串”         //4个包括
字符串8:“字符串asfd对比”        //4个包括
(另外字符串是日文的,是不是和对比中文是一样的呢?)在C#.net 中用什么函数可以将每个字符取出放在数组中呢?怎样用正则表达式判断,指定字符串中包括多少个字符串1中的字符呢,比如包括百分之多少?可能有点麻烦,我是个新手,实在搞不出来,谢谢各位了!!!!
(我在VB.NET里也发了个这样的帖,如果哪位大侠帮我解决了这个头疼的问题,另外那100分也送了。)
http://community.csdn.net/Expert/topic/5263/5263831.xml?temp=.9253504

解决方案 »

  1.   

    private void button1_Click(object sender, System.EventArgs e)
    {
    string str1 = this.textBox1.Text; //字符串1
    string str2 = this.textBox2.Text; //字符串2,3,4,5,6,。 int count ;
    count = 0;
    string str3 = string.Empty; foreach(char c in str2)
    {
    foreach(char d in str1)
    {
    if ( d == c)
    {
    count ++ ;
    str3 = str3 + d.ToString();
    }
    } } if (count > 2 ) 
    {
    MessageBox.Show("符合");
    } this.textBox3.Text = str3;
    }
    }
      

  2.   

    private void button1_Click(object sender, System.EventArgs e)
    {
    string str1 = this.textBox1.Text; //字符串1
    string str2 = this.textBox2.Text; //字符串2,3,4,5,6,。 int count ;
    count = 0;
    string str3 = string.Empty; foreach(char c in str2)
    {
    if(str1.IndexOf(c) > 0 )
    {
    count ++ ;
    str3 = str3 + c.ToString();
    }
    } if (count > 2 ) 
    {
    MessageBox.Show("符合");
    }
    this.textBox3.Text = str3;
    }
      

  3.   

    lz :copico(路北)已经解决了你的问题。。