Janilabo

Janilabo | BeforeEx() [SCAR Divi]

Apr 28th, 2013
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.76 KB | None | 0 0
  1. {==============================================================================]  
  2.   Explanation: Returns the string before s in str AFTER offset.                  
  3. [==============================================================================}
  4. function BeforeEx(s, str: string; offset: Integer): string;
  5. var
  6.   p, strL: Integer;
  7. begin
  8.   strL := Length(str);
  9.   if ((Length(s) < strL) and (offset < strL)) then
  10.   begin
  11.     p := PosEx(s, str, offset);
  12.     if (p > 1) then
  13.       Result := Copy(str, 1, (p - 1))
  14.     else
  15.       Result := '';
  16.   end else
  17.     Result := '';
  18. end;
  19.  
  20. var
  21.   o: Integer;
  22.   str: string;
  23.  
  24. begin
  25.   ClearDebug;
  26.   str := 'BeforeEx() WORKS! This is BeforeEx() test!';
  27.   o := Pos('This', str);
  28.   WriteLn(BeforeEx(' ', str, (o - 1)));
  29. end.
Advertisement
Add Comment
Please, Sign In to add comment