Best way to reduce multiple whitespace?

I have a Word file which has been translated to text, or raw Excel export from a computer system.

I end up getting a bunch of whitespace where previously it was indentation or tabs.

How do I reduce multiple whitespace to single whitespace?

E.g. from “Vendor : A0123456 Account : 12345”
to “Vendor : A0123456 Account : 12345”

Please note that the above is just an example and there can be variable number of whitespaces depending on the content

Please check this post

One simple way is by using Regex.

The following Regex operation replaces multiple spaces into a single space.

myString = Regex.Replace(myString, "\s+", " ")

Regards,
Karthik Byggari

4 Likes