Janilabo

Janilabo | function ReplaceEx() [Simba]

Aug 25th, 2012
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.51 KB | None | 0 0
  1. function ReplaceEx(Text, FindStr, ReplaceStr: string; Offset: Integer): string;
  2. var
  3.   fsL, tL: Integer;
  4. begin
  5.   fsL := Length(FindStr);
  6.   tL := Length(Text);
  7.   if ((fsL > tL) or (Offset > tL)) then
  8.     Exit;
  9.   if (Offset < 1) then
  10.     Offset := 1;
  11.   Result := (Copy(Text, 1, (Offset - 1)) + Replace(Copy(Text, Offset, ((tL - Offset) + 1)), FindStr, ReplaceStr, [rfReplaceAll]));
  12. end;
  13.  
  14. var
  15.   str: string;
  16.  
  17. begin
  18.   str := 'Janilabo is naab';
  19.   WriteLn(ReplaceEx(str, 'a', 'o', (Pos('abo ', str) + 1)));
  20. end.
Advertisement
Add Comment
Please, Sign In to add comment