Regular Expressions assistance needed

I have a website consisting of dozens, maybe a hundred, html files. Each of these has a date such as "Last Updated: June 3, 2014"

I want to go through and change all of those dates to today's date without having to manually do it. Regular expressions is most likely the best route. If someone could assist with the proper code, that would be great as I am not convfersant in the programming of regular expressions.

Dreamweaver is the platform.
mcpilot1Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
Off the top of my head - here is a small PHP script that should do it. Run it in a folder with COPIES of your files you want to update.
NB: COPY
<?php
// GET ALL HTML FILES
$files = glob('*.html');

// SET OUR NEW DATE STRING
$replace = "Last Updated: " .  date('M d, Y');

// LOOP THROUGH FILES
foreach($files as $f) {
   // LOAD THE FILE CONTENTS
   $data = file_get_contents($f);

   // DO THE REPLACE
   $data = preg_replace('/Last Updated:(.*?) (\d\d?), (\d\d\d\d)/', $replace, $data);

   // PUT THE DATA BACK
   file_put_contents($f, $data);
}

Open in new window

1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mcpilot1Author Commented:
This worked perfectly. Thank you!
0
Julian HansenCommented:
You are welcome.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Regular Expressions

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.