Atunci adaptezi.

$pattern = "/<$tag(.*)?>(.*?)<\/$tag>/";