哪位大虾能不能改成C#语言编写的
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, ComCtrls, PerlRegEx;
type
TForm1 = class(TForm)
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
Memo1: TMemo;
ListBox1: TListBox;
Panel1: TPanel;
Button1: TButton;
Edit1: TEdit;
Label1: TLabel;
Label2: TLabel;
Edit2: TEdit;
Splitter1: TSplitter;
TabSheet3: TTabSheet;
mExclusion: TMemo;
ListBox2: TListBox;
pcre: TPerlRegEx;
procedure Button1Click(Sender: TObject);
procedure ListBox1DblClick(Sender: TObject);
procedure ListBox1Click(Sender: TObject);
private
{ Private declarations }
function Excluded(str: string): Boolean;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses FileList;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
fl : TFileList;
Content : TStringList;
i, j : Integer;
begin
PageControl1.ActivePageIndex := 0;
ListBox1.Items.Clear;
pcre.RegEx := '''.*?[A-Za-z]+.*?''';
Content := TStringList.Create;
fl := TFileList.Create;
fl.Root := Edit1.Text;
fl.Mask := Edit2.Text;
fl.Recursive := True;
fl.Update;
for i := 0 to fl.Count - 1 do
begin
if Excluded(fl[i]) then
Continue;
Content.LoadFromFile(fl[i]);
pcre.Subject := Content.Text;
if pcre.Match then
repeat
if not Excluded(pcre.MatchedExpression) then
begin
ListBox1.AddItem(fl[i], nil);
Break;
end;
until not pcre.MatchAgain;
end;
fl.Free;
Content.Free;
end;
function TForm1.Excluded(str: string): Boolean;
var
i : Integer;
begin
Result := False;
for i := 0 to mExclusion.Lines.Count - 1 do
begin
if Pos(mExclusion.Lines[i], str) > 0 then
begin
Result := True;
Break;
end;
end;
end;
procedure TForm1.ListBox1DblClick(Sender: TObject);
var
fn : string;
begin
fn := ListBox1.Items[ListBox1.ItemIndex];
try
Memo1.Lines.LoadFromFile(fn);
PageControl1.ActivePageIndex := 1;
except
end;
end;
procedure TForm1.ListBox1Click(Sender: TObject);
var
fn : string;
sl : TStringList;
i : Integer;
begin
ListBox2.Items.Clear;
sl := TStringList.Create;
fn := ListBox1.Items[ListBox1.ItemIndex];
try
sl.LoadFromFile(fn);
pcre.RegEx := '''.*?[A-Za-z]+.*?''';
for i := 0 to sl.Count - 1 do
begin
pcre.Subject := sl[i];
if pcre.Match then
begin
if not Excluded(sl[i]) then
ListBox2.AddItem(sl[i], nil);
end;
end;
except
end;
sl.Free;
end;
end.