If you try to use preg_match on strings, which do have multiple lines you run into the problems that they actually won't match at all.
This can be easily fixed by adding s-modifier, so:
/\[(code)\](.*?)\[\/code\]/
becomes to
/\[(code)\](.*?)\[\/code\]/s
and works like a charm!