Sorry for omitting context. Perhaps the OP is parsing HTML and needs something like Tidy (if you're wondering why I didn't include a link it's for 2 reasons: I'm lazy and google exists)? // mark -