Janilabo

Janilabo | Count() [Simba]

Jun 21st, 2012
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.45 KB | None | 0 0
  1. function Count(s, str: string): Integer;
  2. var
  3.   i, sL, strL: Integer;
  4. begin
  5.   sL:= Length(s);
  6.   strL := Length(str);
  7.   if (sL > strL) then
  8.     Exit;
  9.   for i := 1 to ((strL - sL) + 1) do
  10.     if (Copy(str, i, sL) = s) then
  11.       Inc(Result);
  12. end;
  13.  
  14. var
  15.   s, str: string;
  16.  
  17. begin
  18.   ClearDebug;
  19.   str := '|||| Count() Test ||| *** ||| Smooth. ||||';
  20.   s := '||';
  21.   WriteLn('Count of "' + s + '" in string: ' + IntToStr(Count(s, str)) + '!');
  22. end.
Advertisement
Add Comment
Please, Sign In to add comment