3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = <<<TXT /something/ and /something?foo=bar are ok, but /another/something/ is not. Ah, /something is ok without trailing slash is ok as well. TXT; $r = '~(?:\s|^)(/something/?(?:\?[^\s]+)?)~'; preg_match_all($r, $str, $m); print_r($m[1]);

preferences:
177.25 ms | 405 KiB | 5 Q