我想在某字符串中,比如'中华人民共和国'找出'人'这个字的位置,比如说应该是5,可以用什么函数?谢谢,请指点

解决方案 »

  1.   

    copy('中华人民共和国',5,2)='人'
      

  2.   

    Edit1.Text := IntToStr(Pos('人', '中华人民共和国'));
    若找不到,则返回0;只要返回大于0,则为在其中位置
      

  3.   

    Delphi syntax:function AnsiPos(const Substr, S: string): Integer;DescriptionCall AnsiPos to obtain the byte offset of the Substr parameter, as it appears in the string S. For example, if Substr is the string "AB", and S is the string "ABCDE", AnsiPos returns 1. If Substr does not appear in S, AnsiPos returns 0.Note: This function supports multi-byte character sets (MBCS).