第1个回答 2013-04-06
//功能:子串在主串第几次出现的位置function PosEx(substring,s:string;times:Integer):Integer;var nCount,nIndex:Integer;begin nCount:=0; while times>0 do begin nIndex:=Pos(substring,s); if nIndex<=0 then break; s:=Copy(s,nIndex+1,Length(s)-nIndex); nCount:=nCount+nIndex; times:=times-1; end; Result:=nCount;end;
第2个回答 2013-04-05
DELPHI的函数很多,被明日科技写入函数大全的就是厚厚一本400多页的书.因此没有多少人去读完它,只是满足于几十个常用函数而已.
pos在找到子串的首次位置后,我一般是采用在这个位置将字符串切断,并再次查找下一个子串位置.