Advertisement
mixster

mixster

Sep 25th, 2008
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.53 KB | None | 0 0
  1. program New;
  2. function InsertBetweenMix(str, insB, insA, frm, unt: string): string;
  3. var
  4.   fI, uI: Integer;
  5. begin
  6.   repeat
  7.     fI := PosEx(frm, str, uI + 1);
  8.     uI := PosEx(unt, str, fI + 1);
  9.     if fI <= 0 then
  10.       Break;
  11.     if uI <= 0 then
  12.       uI := Length(str);
  13.     Insert(insB, str, fI);
  14.     IncEx(uI, Length(insB) + 1);
  15.     Insert(insA, str, uI);
  16.     IncEx(uI, Length(insA));
  17.   until false;
  18.   Result := str;
  19. end;
  20.  
  21. begin
  22.   Writeln(InsertBetweenMix('Hello {world}, how are you {the world}?', '[', ']', '{', '}'));
  23. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement