Forum Moderators: coopster
So, how to I test for newline(s) in a preg_replace()?
Trying to clean up some poor code in a CMS. I have this, which works:
$pattern = '{<h1>[ *]<a href(.*)</a>[ *]</h1>}';
$replacement = '<h2><a href$1</a></h2>';
$string = '<h1><a href="http://localhost/folder/file.htm" class="class">Title</a></h1></td>';
$ntext=preg_replace($pattern, $replacement, $string);
I can test for the spaces, but have been unable to get the test for a newline to work. Have tried \n without success.
BTW, don't ask why I am doing this rather than hacking the CMS code. This really is an easier way on this one ;)