In a file I have the kind of line:
I have lot of spaces in me.
and I replace every space by one space with this powershell code:
$String = "I have lot of spaces in me."
while ($String.Contains(" "))
{
$String = $String -replace " "," "}
the result is :
I have lot of spaces in me.
I would like to do that for each line in a txt file. could you give me the best way to do that?
Part two:
How can I replace something only when there are more than one whitespace with e.g. ;
?
The response will be:
;4828;toto;toto;Ticket;0112APPT
and not :
;4828;toto toto;Ticket;0112APPT
To be clear, I would like replace only two White-Space by the Character ;