Janilabo

Janilabo | BeforeEx() [Simba]

Jun 21st, 2012
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.45 KB | None | 0 0
  1. function BeforeEx(s, str: string; offset: Integer): string;
  2. var
  3.   p, strL: Integer;
  4. begin
  5.   strL := Length(str);
  6.   if (Length(s) >= strL) or (offset >= strL) then
  7.     Exit;
  8.   p := PosEx(s, str, offset);
  9.   if (p > 1) then
  10.     Result := Copy(str, 1, (p - 1));
  11. end;
  12.  
  13. var
  14.   o: Integer;
  15.   str: string;
  16.  
  17. begin
  18.   ClearDebug;
  19.   str := 'BeforeEx() WORKS! This is BeforeEx() test!';
  20.   o := Pos('This', str);
  21.   WriteLn(BeforeEx(' ', str, (o - 1)));
  22. end.
Add Comment
Please, Sign In to add comment