Einzelnen Beitrag anzeigen

omata

Registriert seit: 26. Aug 2004
Ort: Nebel auf Amrum
3.154 Beiträge
 
Delphi 7 Enterprise
 
#2

Re: RichEdit: <i>..</i> kursiv setzen

  Alt 22. Feb 2009, 06:18
Delphi-Quellcode:
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;
RegExpr
  Mit Zitat antworten Zitat