PosCount(
const
Substr, S:
string
): Integer;
var
vLen: Integer;
begin
vLen :
=
Length(Substr);
if
vLen
=
0
then
Result :
=
0
else
Result :
=
(Length(S)
–
Length(StringReplace(S, Substr,
”
, [rfReplaceAll])))
div
vLen;
end
;
procedure
TForm1.FormCreate(Sender: TObject);
begin
ShowMessage(IntToStr(PosCount(
‘
魂牵梦萦
‘
,
‘
魂牵梦萦魂牵梦萦在需要魂牵梦萦
‘
)));
//
3
ShowMessage(IntToStr(PosCount(
‘
牵2
‘
,
‘
魂牵2梦萦魂牵梦萦4梦梦梦魂牵2梦萦
‘
)));
//
2
ShowMessage(IntToStr(PosCount(
‘
2
‘
,
‘
123254879935212
‘
)));
//
4
end
;
转载于:https://www.cnblogs.com/klaus/archive/2010/09/01/1815036.html
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/110729.html原文链接:https://javaforall.net