$buf = preg_replace('#articles\.php\?cat_id=([0-9]*?)(\'|")#si', 'artykul/kategoria/\1\2', $buf);