If you're trying to slurp up the preceding and proceding tag
indiscriminately, can't you just tack this onto the start of
your regexp:
'(<
^<>*>
^<>*)?'
and this onto the end:
'(
^<>*</
^<>*>)?'
Or am I missing something? (My square brackets are being
eaten, but hopefully you get the idea...)