Janilabo

Janilabo | Count2() [Simba]

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