Removing spaces from a variable input using PowerShell 4.0

前端 未结 5 1775
青春惊慌失措
青春惊慌失措 2021-02-05 03:59

I\'ve tried a few things already but they don\'t seem to work for some reason.

Basically what I\'m attempting to do is have a user input a value using the \"Read-host\

5条回答
  •  天命终不由人
    2021-02-05 04:25

    You're close. You can strip the whitespace by using the replace method like this:

    $answer.replace(' ','')

    There needs to be no space or characters between the second set of quotes in the replace method (replacing the whitespace with nothing).

提交回复
热议问题