Mega Code Archive

 
Categories / Delphi / LAN Web TCP
 

To extract the plain text from html string

Title: to extract the plain text from html string Today I want to publish small procedure that extract the plain text from html-formatted string function StripHTMLTags(const strHTML: string): string; var P: PChar; InTag: Boolean; i, intResultLength: Integer; begin P := PChar(strHTML); Result := ''; InTag := False; repeat case P^ of '': InTag := False; #13, #10: ; {do nothing} else if not InTag then begin if (P^ in [#9, #32]) and ((P+1)^ in [#10, #13, #32, #9, '', '', [rfReplaceAll]); Result := StringReplace(Result, '