输入一句话以后判断这句话里有没有想要的那个关键词.
比如输入一句"小明的爸爸是谁?" 判断这句话里有没有"是谁"要用一个什么样的形式去写?
最好能稍微把过程讲明白一点,谢谢了...

解决方案 »

  1.   

    InStr InStr(string1,string2[, compare]) 返回string1字符串在string2字符串中第一次出现的位置 
      

  2.   

    正则表达式
    string input="小明的爸爸是谁?";
    string pattern = "是谁";
    Match match = Regex.Match(fi.Name, sname);
    if (match.Success)
    {
        //TODO
        ......
    }
      

  3.   

    IndexOf   定位字符串中第一次出现某个给定子字符串或字符的位置
      

  4.   

    不好意思,改一下,呵呵
    string input="小明的爸爸是谁?";
    string pattern = "是谁";
    Match match = Regex.Match(input, pattern );
    if (match.Success)
    {
        //TODO
        ......
    }
      

  5.   

    string s = "abc";
    if(s.Contains("a"))
    {
       。。//todo
      

  6.   

    IndexOf() 
    查找字串中指定字符或字串首次出现的位置,返首索引值,如: 
    str1.IndexOf("字"); //查找“字”在str1中的索引值(位置) 
    str1.IndexOf("字串");//查找“字串”的第一个字符在str1中的索引值(位置) 
    str1.IndexOf("字",start,end);//从str1第start+1个字符起,查找end个字符,查找“字”在字符串STR1中的位置[从第一个字符算起]注意:start+end不能大于str1的长度