<?php
$string = '[...]http://localhost/project/gallery/http://localhost/project/case/category#/img#/case#/http://localhost/project/case/main-category/45/main/http://localhost/project/sitemap[...]';
if (preg_match('~/case/([^/]+)/(\d{2,3})/([^/]+)/~i', $string, $m))
   print_r($m);
?>