I originally have this preg_match_all pattern for the HTML img tag, but how do I find the first occurrence for a bbcode?
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $content, $matches);
[img]http://path/to/img.png[/img]
Which should return the content of the [img] bbcode
Try this :
Demo :
http://regexr.com?30mks