I am assuming you are writing bbcode. If so writing an actual parser would be faster but if you just want to do search and replace something like
preg_replace('/\[url=(.*?)\](.*?)\[\/url\]/i', '<a href='.$1.'>'.$2.'</img>');
I cannot remember the jsfiddle like site that lets you show regexp so if someone know it please leave it in the comments.
Also if you are gonna just copy and paste my code into your bbcode seach and replace file... DONT it's vulnerable to xss injection and really not an amazing expression it just is an example.