Janilabo Posted May 22, 2012 Share Posted May 22, 2012 Returns the text before S in STR. Example included. Before [scar]function Before(s, str: string): string; var p: Integer; begin if (Length(s) >= Length(str)) then Exit; p := Pos(s, str); if (p > 1) then Result := Copy(str, 1, (p - 1)); end; var str: string; begin ClearDebug; str := 'Before() WORKS! Test to see if Before() works correctly.'; WriteLn(Before(' Test', str)); end.[/scar] Quote Link to comment Share on other sites More sharing options...