我在取  " <[email protected]> " 我想把”<“,">"中的字符取出来。
我用的是这样一个方法:
str:string;
ipos1,ipos2:integer;
  str:='  "阿枫<[email protected]>"'
  ipos1:=pos('<',str);
  ipos2:=pos('>',str);
  str:=copy(str,ipos1+1,ipos2-1);
为什么这个str的值最后是[email protected]>  按道理因该是[email protected] 请问这到底是什么原因。

解决方案 »

  1.   

    copy的第二个参数是字符个数,应该这样:
    str:=copy(str,ipos1+1,ipos2-ipos1-1);
      

  2.   

    copy的第三个参数是字符个数,应该这样:
    str:=copy(str,ipos1+1,ipos2-ipos1-1);
      

  3.   

    str:=copy(str,ipos1+1,ipos2-1);
    改为str:=copy(str,ipos1+1,ipos2-1-ipos1);
    copy后面的参数不是结束位置。
      

  4.   

    pos是用来定位的,
    COPY用来得到你要的结果
      

  5.   

    函数原型为 
    function Copy(S; Index, Count: Integer): string;
    function Copy(S; Index, Count: Integer): array;Count为长度
    最后一个参数你理解错了
    所以正确的为
    str:=copy(str,ipos1+1,ipos2-ipos1-1);