Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function LastBefore(s, str: string): string;
- var
- l, p, lp: Integer;
- begin
- l := Length(str);
- if (Length(s) > l) then
- Exit;
- repeat
- p := PosEx(s, str, (p + 1));
- if (p > 0) then
- lp := p;
- until (p <= 0);
- if (lp > 0) then
- Result := Copy(str, 1, (lp - 1));
- end;
- var
- str: string;
- begin
- ClearDebug;
- str := 'LastBefore() WORKS! WORKS? Right?! ;)';
- WriteLn(LastBefore(' WORK', str));
- end.
Advertisement
Add Comment
Please, Sign In to add comment