Thanks StarX for your help. The process takes place on the server itself, so I don't need to pull the content to a client, therefore wget doesn't fit the bill.

I want to use a regex for substitution on the URLs in the files, but I have the following issue:

I want to globally change the following: <a href="http://www.mysite.org/?page=contacts"><font color="#269BD5">

into: <a href="pages/contacts.htm"><font color="#269BD5">

You'll notice that the match would be http://www.mysite.org/?page= but I also need to add a ".htm" to the end of the contacts so it becomes contacts.htm This part of the URL is variable, so how can I use a regex replace to match the above and also add a ".htm" to the end of that variable part?

Here are a few dummy URLs for example so you can see the pattern and the variable too.

<a href="http://www.mysite.org/?page=newsletter"><font color="#269BD5">

change to: <a href="pages/newsletter.htm"><font color="#269BD5">

<a href="http://www.mysite.org/?page=faq">

change to: <a href="pages/faq.htm">

So, again the script needs to replace all the full absolute URL links with nothing and replace the PHP "?page=" with just the variable page name (i.e. contacts) plus the ".htm"

Is there a combination of Perl code and/or regex that can do this? Any help would be greatly appreciated!


In reply to Re^2: Need direction on mass find/replacement in HTML files. by kevin4truth
in thread Need direction on mass find/replacement in HTML files. by kevin4truth

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.