Jump to content
Janilabo

BeforeEx

Recommended Posts

"Upgrade" function for Before - with this function you can use offset. Example included.

 

BeforeEx

[scar]function BeforeEx(s, str: string; offset: Integer): string;

var

p, strL: Integer;

begin

strL := Length(str);

if (Length(s) >= strL) or (offset >= strL) then

Exit;

p := PosEx(s, str, offset);

if (p > 1) then

Result := Copy(str, 1, (p - 1));

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.[/scar]

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...