function GetSubStrNum(const SubStr,Str: WideString): Integer; var pw: PWideChar; i,SubLen: Integer; begin Result := 0; pw := PWideChar(Str); SubLen := Length(SubStr); while i > 0 do begin i := Pos(SubStr, pw); Inc(pw, i - 1 + SubLen); if Boolean(i) then Inc(Result); end; end;
function GetSubStrNum(const SubStr, Str: widestring ): Integer; var i,x: Integer; Len,LenSubStr: Integer; begin Result := 0; i := 1; LenSubStr := Length(SubStr); Len := Length(Str) - LenSubStr + 1; while i <= Len do begin if Str[i] = SubStr[1] then begin x := 1; while (x < LenSubStr) and (Str[i+x] = SubStr[x+1]) do Inc(x); if (x = LenSubStr) then Result := Result + 1; Inc(i,x); end else Inc(i); end; end;