PowerShell: Removing White Space Characters
Requirement:
We have 1000+ text files with incorrect formats. We need a script to remove white spaces as a start and later we may do formatting manually.
Solution:
It's quite possible to do it using PowerShell. But, very difficult to predict your source.
PowerShell Code:
"My File has in correct format" -replace "\s{2,}" , " "
You can us regular expressions to do it.
Note: This is a base logic - 'Do REGEX as required.' If there is a space between one single word it will not be formatted.
Enjoy PowerShell !!
Other Languages
This article is also available in the following languages: