<?php $names = ['[foo]bar', 'baz', '[blarg]blah']; foreach($names as $name) { preg_match('/^(\[.*?\])?(.*)$/', $name, $match); var_dump($match); }
You have javascript disabled. You will not be able to edit any code.