
28.03.2012, 07:53
|
Так проходящий
|
|
Регистрация: 18.07.2011
Сообщения: 805
Версия Delphi: 7Lite
Репутация: 6063
|
|
PHP код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
ListBox1: TListBox;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
type abc = set of char;
function no_empty_lines(str: string): string;
begin
while str <> StringReplace(str, #13#10#13#10, #13#10, [rfReplaceAll]) do
str := StringReplace(str, #13#10#13#10, #13#10, [rfReplaceAll]);
if pos(#13#10, str) = 1 then
str := StringReplace(str, #13#10, '', []);
result := str;
end;
function get(str: string; needed: abc = ['a'..'z', 'A'..'Z']): string;
var i: integer;
begin
for i := 0 to 255 do
if not (char(i) in needed) then
str := StringReplace(str, char(i), #13#10, [rfReplaceAll]);
result := no_empty_lines(str);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ListBox1.Items.Text := get(Edit1.Text);
end;
end.
|