3v4l.org

run code in 300+ PHP versions simultaneously
<?php $subject = "text text text text [hello] text (hello2) (hello3) text"; $pattern = '/^\[([^)]*)\]/'; preg_match($pattern, $subject, $matches, PREG_OFFSET_CAPTURE, 3); print_r($matches);

preferences:
36.72 ms | 402 KiB | 5 Q