Possibly with some linebreak-swallowing machinery, bearing in mind
that (i) all regexp implementations are slightly different (I’ve been
using Perl and Java regex more recently than Max) and (ii) my regexp
chops are pretty rusty and (iii) your input syntax isn’t specified; so
consider this a starting point, and do a LOT of testing.
It’s like the old joke: you have a problem, so you come up with a
regexp to solve it. You now have two problems.