memo1文本内容:
fygjh5jghg
trhfg5jkhh
fjhfhyhdf
6695thu
fjjy5hghfunit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, OleServer, VBScript_RegExp_55_TLB;type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Memo2: TMemo;
    Memo3: TMemo;
    Button1: TButton;
    Button2: TButton;
    RegExp1: TRegExp;
    Button3: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
machs: IMatchCollection;
Matchs: Match;
submatch: ISubMatches;
i : integer;
begin
  RegExp1.Global := true;
  RegExp1.IgnoreCase := True;
  RegExp1.Pattern := '5.*';
  machs := RegExp1.Execute(memo1.text) as IMatchCollection;
  for i := 0 to machs.Count - 1 do
    begin
      Matchs := machs.Item[i] as Match;
      submatch := Matchs.SubMatches as ISubMatches;
      memo2.lines.Add(matchs.Value);
    end;    RegExp1.Pattern :=   '5';              
    memo3.Text := RegExp1.Replace(memo2.Text,'');
end;
procedure TForm1.Button2Click(Sender: TObject);
var
machs: IMatchCollection;
Matchs: Match;
submatch: ISubMatches;
i : integer;
aaa : Tstrings;
bbb: Tstrings;
begin
  aaa := TStringList.Create;
  bbb := TStringList.Create;
  RegExp1.Global := true;
  RegExp1.IgnoreCase := True;
  RegExp1.Pattern := '5.*';
  machs := RegExp1.Execute(memo1.text) as IMatchCollection;
  for i := 0 to machs.Count - 1 do
    begin
      Matchs := machs.Item[i] as Match;
      submatch := Matchs.SubMatches as ISubMatches;
      aaa.Add(matchs.Value);
    end;  RegExp1.Pattern :=   '5';
  bbb.Text := RegExp1.Replace(aaa.Text,'');
  memo3.Text := bbb.Text;
end;procedure TForm1.Button3Click(Sender: TObject);
begin
 memo2.Clear;
 memo3.Clear;
end;end.为什么按钮1点击后获得的结果是:
jghg
jkhh
thu
hghf而按钮2点击后获得的结果是:
jghgjkhhthuhghf我想使用TStringList不使用memo获得没有空行的结果,请教如何修改代码?