in reply to looking for a regexp
s/\s([^<]*<[^>]*>|$)/ $1/g;
-- Casey
See Substitution outside of HTML TAGS or other threads turned up by searchng for 'html tags'.