Janilabo Posted May 22, 2012 Share Posted May 22, 2012 Returns the text after last S in STR. Example included. LastAfter [scar]function LastAfter(s, str: string): string; var sL, l, p, lp: Integer; begin l := Length(str); sL := Length(s); if (sL > 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, (lp + sL), ((1 + l) - (lp + sL))); end; var str: string; begin ClearDebug; str := 'This is LastAfter() test. YEP, let''s test. LastAfter() WORKS!'; WriteLn(LastAfter('test. ', str)); end.[/scar] Quote Link to comment Share on other sites More sharing options...