in reply to regex'ing source code

You didn't say what language the source code is, so I'm guessing perl :)

In which case, does perltidy -html do the right thing?