RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L,QSA]
$string = 'dd dss рис. 69 ddd';
$pattern = '~(рис\. (\d+))~';
$replacement = '<a href="#pict$2">$1</a>';
echo preg_replace($pattern, $replacement, $string);