我想查找一个字符串的是否含有某个单词中文的。比如:“这个时候我在上CSDN。”我想查找里面是含有“时候”。请问该怎么做?用什么函数?

解决方案 »

  1.   

    if Pos('时候',String1)>0 then
      

  2.   

    i := Pos('时候','这个时候我在上CSDN。')
    if i>0 then ...
      

  3.   

    pos或posEx或ansiPos都可以的,其中anspos主要是防止汉字取子串时会取到关个汉字的情况
      

  4.   

    function Pos(Substr: string; S: string): Integer;Pos searches for Substr within S and returns an integer value that is the index of the first character of Substr within S. Pos is case-sensitive. If Substr is not found, Pos returns zero.
      

  5.   

    Pos这个函数用来查找子串的
    Pos(subStr,SourceStr);第一个参数代表你要找的子串 第二个参数代表原串
    if Pos('时候',String1)>0 then 
      //你找到该子串