Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {==============================================================================]
- Explanation: Returns the string before s in str AFTER offset.
- [==============================================================================}
- function BeforeEx(s, str: string; offset: Integer): string;
- var
- p, strL: Integer;
- begin
- strL := Length(str);
- if ((Length(s) < strL) and (offset < strL)) then
- begin
- p := PosEx(s, str, offset);
- if (p > 1) then
- Result := Copy(str, 1, (p - 1))
- else
- Result := '';
- end else
- Result := '';
- end;
- var
- o: Integer;
- str: string;
- begin
- ClearDebug;
- str := 'BeforeEx() WORKS! This is BeforeEx() test!';
- o := Pos('This', str);
- WriteLn(BeforeEx(' ', str, (o - 1)));
- end.
Advertisement
Add Comment
Please, Sign In to add comment