Isn't what you're trying to do what is known as a 'regular expression' - i.e. a way to automate the tidying of lots of text, and therefore doesn't really require an Excel function at all?
This is merely a text function so I'd assume you can export as CSV and perform a suitable regular...