I have the following string.
$string = 'Hello there how are <a
href="http://eem.mydomain.com/2015/06/court-compels-epa-to-
respond.html">some link name</a> there how are there how are
<a href="http://eem.mydomain.com/2014/03/wv-clean-air-act-case.html">another
link name</a> ';
I need a PHP function that will convert the URLs in the string to the following URLs.
$new_string = 'Hello there how are <a href="http://eem.mydomain.com/energy-
environment-blog/court-compels-epa-to-respond">some link name</a> there how
are there how are
<a href="http://eem.mydomain.com/energy-environment-blog/wv-clean-air-act-
case">another link name</a> ';
In the new URLs, the year and month needs to be replaced with 'energy-environment-blog' and the .html extension needs to be removed. Can anyone help writing a pattern that will match the varying year/date in the URL and removal of the .html extension. That part is tripping me up.
<?php
$pattern = "";
$replacement = '';
$new_string = preg_replace($pattern, $replacement, $string);
?>