Выбрать из текста только те слова, которые состоят из чисел — Delphi(Делфи)

procedure TForm1.Button1Click(Sender: TObject);
var
  i: integer;
  IsNum: boolean;
  temp, SourceString, ResultString: string;
begin
  IsNum := false;
  temp := '';
  ResultString := '';
  SourceString := Memo1.Text;
  for i := 1 to length(SourceString) do
  begin
    if SourceString[i] = ' ' then
    begin
      if not IsNum then
        if length(temp) = 5 and pos(temp, 'A') = 0 then
          ResultString := ResultString + temp + ', ';
      temp := '';
      IsNum := false;
      continue;
    end;
    temp := temp + SourceString[i];
    IsNum := IsNum or SourceString[i] in ['1', '2', '3', '4', '5', '6', '7',
      '8', '9', '0'];
  end;
  ResultString := copy(ResultString, 1, length(ResultString) - 2);
end;

Leave a Comment

34 − 33 =