Jump to content

HtmlMemo Extract Plain Text - How ?


andyhill

Recommended Posts

3 hours ago, andyhill said:

<b style=""><font color="#ff0000">Hello</font></b>

I need text "Hello" only (no markup)

 

27 minutes ago, andyhill said:

Yes, I was hoping for UniGUI to provide this capability - Thanks

For start, you can try to use this approach:

procedure TMainForm.UniButton1Click(Sender: TObject);
  function StripHTML(S: string): string;
  var
    TagBegin, TagEnd, TagLength: integer;
  begin
    TagBegin := Pos( '<', S);

    while (TagBegin > 0) do begin
      TagEnd := Pos('>', S);
      TagLength := TagEnd - TagBegin + 1;
      Delete(S, TagBegin, TagLength);
      TagBegin:= Pos( '<', S);
    end;

    S := StringReplace(S, '&nbsp;', ' ', [rfReplaceAll]);

    Result := S;
  end;
begin
  UniMemo1.Lines.Text := StripHTML(UniHTMLMemo1.Lines.Text)
end;

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...