in reply to Re: Convert Relative to Absolute URLs on-the-fly
in thread Convert Relative to Absolute URLs on-the-fly

HTML parsing would be the ideal way to do it if one is interested in extracting the links (and/or information from other tags) from the fetched page.
I just wanted to make sure that when saving a fetched page, I save all absolute links so that next time when I open the page, I can navigate easily. I wasn't interested in extracting any information from the page. So, I came up with the RegEx above, which does the job in just 1 line.
  • Comment on Re^2: Convert Relative to Absolute URLs on-the-fly

Replies are listed 'Best First'.
Re^3: Convert Relative to Absolute URLs on-the-fly
by merlyn (Sage) on Feb 07, 2008 at 15:10 UTC
    "does the job"? You mean "does the job most of the time, as long as there is no unusual HTML there".

    I'm just trying to point out that parsing HTML with a simple regex will fail from time to time, and should be advised against when there are other easy-to-use technologies that will get it right in just a few more lines of code. Hence, my followup to your post.