procedure HTMLtoRTF(
html:
string; RichEdit:TRichEdit);
var StringStreamRead, StringStreamWrite:TStringStream;
RegExpr:TRegExpr;
Temp:
string;
begin
RichEdit.Lines.BeginUpdate;
StringStreamRead:=TStringStream.Create('
');
RegExpr:=TRegExpr.Create;
try
RichEdit.Text:=
html;
RichEdit.PlainText:=false;
RichEdit.Lines.SaveToStream(StringStreamRead);
RegExpr.ModifierG:=false;
RegExpr.Expression:='
[i](.*)[/i]';
Temp:=StringStreamRead.DataString;
Temp:=RegExpr.Replace(Temp, '
[i]\\i $1\\i0 [/i]', true);
RegExpr.Expression:='
[b](.*)[/b]';
Temp:=RegExpr.Replace(Temp, '
[b]\\b $1\\b0 [/b]', true);
StringStreamWrite:=TStringStream.Create(Temp);
try
RichEdit.Lines.LoadFromStream(StringStreamWrite);
finally
StringStreamWrite.free;
end;
finally
StringStreamRead.free;
RegExpr.free;
RichEdit.Lines.EndUpdate;
end;
end;