更改后的代码,分条件判断。由于是重复查找,效率极差,懒得去改。
我不想再看到这段代码了[
]
procedure TForm1.Button1Click(Sender: TObject);
var
sels,sele:longint;
s:string;
begin
s := richedit1.Text;
screen.Cursor := crHourGlass;
while pos('<!--',s) <> 0 do
begin
sels := pos('<!--',s);
sele := pos('-->',s);
if sele = 0 then break;
if sels < sele then
delete(s,sels,sele-sels+3);
end;
while pos('<style',s) <> 0 do
begin
sels := pos('<style',s);
sele := pos('</style>',s);
if sele = 0 then break;
if sels < sele then
delete(s,sels,sele-sels+8);
end;
while pos('<script',s) <> 0 do
begin
sels := pos('<script',s);
sele := pos('</script>',s);
if sele = 0 then break;
if sels < sele then
delete(s,sels,sele-sels+9);
end;
while pos('<',s) <> 0 do
begin
sels := pos('<',s);
sele := pos('>',s);
if sele = 0 then break;
if sels > sele then break;
delete(s,sels,sele-sels+1);
end;
richedit1.Text := s;
richedit1.perform(wm_vscroll,sb_top,0);
screen.Cursor := crDefault;
end;