RISOLTO !
Ho risolto con questa regex:
codice:
$text = preg_replace("#\[code\=(\w+)\](.+?)\[/code\]#ei", "highlightcode('$2', '$1')", $text);
Adesso aggiungo anche il supporto agli spazi, grazie