$buf = preg_replace('#articles.php?cat_id=([0-9]*?)('|")#si', 'art-cat-1.html2', $buf); $buf = preg_replace('#articles.php#si', 'art.html', $buf);