3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = 'this is some sample'; $base = 'this is some sample [shortcode/ attr="somth"]dfdfdfdf[shortcode]text[/shortcode][shortcodeniedzialajacy]'; $pattern = "/\[(shortcode)([ ][a-zA-Z0-9\"'=\\s]*\\]|\\])/"; $matches = array(); preg_match($pattern, $string, $matches); print_r($matches);

preferences:
37.29 ms | 402 KiB | 5 Q