For a while now, we have had support for regular expressions in Delphi. This came in handy when I needed a way to extract all links from a HTML page. Turns out it was not too difficult, and the following code snippet takes care of it:
procedure ProcessLinks(const Html: String); var RegEx: TRegEx; Match: TMatch; begin RegEx := TRegEx.Create( '
.*?', [roIgnoreCase, roMultiline] ); for Match in RegEx.Matches(Html) do if Match.Success and (Match.Groups.Count > 1) then WriteLn('LINK:' + Match.Groups.Value); WriteLn('DONE'); end;