Use preg_replace()
Example converting :
eregi_replace()
$bbcodes = array(
'\\[img\\]([^\\\'\;\?([]*)\.(jpg|jpeg|gif|png)\\[/img\\]' => '<img src="\\1.\\2" alt="" />',
'\\[img=([^\\\'\;\?([]*)\.(jpg|jpeg|gif|png)\\]([^\\[]*)\.(jpg|jpeg|gif|png)\\[/img\\]' => '<a href="\\1.\\2"><img src="\\3.\\4" alt="" /></a>',
'\\[url\\]([^\\([]*)\\[/url\\]' => '<a href="\\1">\\1</a>',
'\\[style=([1-9]{1})\\]([^\\[]*)\\[/style\\]' => '<span class="bbstyle\\1">\\2</span>'
..................................
preg_replace()
$bbcodes = array(
'/\[img\]([^\\\'\;\?[]*)\.(jpg|jpeg|gif|png)\[\/img\]/i' => '<img src="$1.$2" alt="" />',
'/\[img=([^\\\'\;\?[]*)\.(jpg|jpeg|gif|png)\]([^\\[]*)\.(jpg|jpeg|gif|png)\[\/img\]/i' => '<a href="$1.$2"><img src="$3.$4" alt="" /></a>',
'/\[url\]([^\\([]*)\[\/url\]/i' => '<a href="$1">$1</a>',
'/\[style=([1-9]{1})\]([^\\[]*)\[\/style\]/i' => '<span class="bbstyle$1">$2</span>'
..................................
Forever unshaven, red-eyed, detached from reality, with his cockroaches in my head. And let it always will be!