Q:

Spinning content in Delphi?

I'd like to create a simple content spinner that will work like this:

I type a text in Memo1 with some delimiters(e.g {This is a simple text|Here We can find a simple text|Here are just some regular words} {which I want to spin|that I want to change|that I need to change}, {please|I need to know}, {what can I do?|how can I do it?} {Thank You|Thanks}).
The function will randomize the strings based in those delimiters and output them to Memo2. One random output for this would be "Here We can find a simple text that I need to change, please, how can I do it? Thank You".

It's important to keep the linebreaks and spaces. Another important thing is to never output results identical one another. 
So basically it will sort the words/sentences based on the delimiters and then create random content based on what I want. It looks simple, I could do it with numbers but can't really think in a way to do it with text. Any help?

A:

Just a simple sample to get you started.
uses
  StrUtils, System.Types, Math;

function MakeSentence(const AText, ADelimiter: string): string;
var
  _SentenceParts: TStringDynArray;
  _SubParts: TStringDynArray;
  i: Integer;
begin
  Result := '';

  if not AnsiContainsText(AText, '{') then // ...other checks
    Exit;

  _SentenceParts := SplitString(AText, '}');
  for i := 0 to Length(_SentenceParts) - 1 do
  begin
    _SentenceParts[i] := Copy(Trim(_SentenceParts[i]), 2,
      Length(_SentenceParts[i]));
    // Punctuation, etc
    _SentenceParts[i] := StringReplace(_SentenceParts[i], '{', '',
      [rfIgnoreCase]);
  end;

  for i := 0 to Length(_SentenceParts) - 1 do
  begin
    _SubParts := SplitString(_SentenceParts[i], ADelimiter);
    if Length(_SubParts) > 0 then
      Result := Result + ' ' + _SubParts[RandomRange(0, Length(_SubParts) - 1)];
  end;
end;

Usage:
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
  Memo2.Text := MakeSentence(Memo1.Text, '|');
end;

