使用pos函数来查找字符第一次出现的位置 pos(要查找的字符串,在字符串中查找)

 

var
str1:string;
i,j:integer;
begin
str1:='dsf4654f6<ds>ad' ;
j:=pos('<',str1);//在字符串str1中查找"<"
if j<>0 then //得到的j是字符串中出现的位置,是整型
showmessage('<'+'在第'+inttostr(j)+'个位置');
end;



posted on 2011-11-06 12:25  del88  阅读(4)  评论(0编辑  收藏  举报