-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Read-Host: Show how to trim leading and trailing whitespace from user input #10088
Comments
I don't think this belongs in the |
@sdwheeler, I find the reasoning in the linked comment specious, and I will respond in detail there. In summary, let me say: As noted, wanting to remove incidental whitespace is the typical use case. That |
Prior to this change, the documentation for the `Read-Host` cmdlet didn't include information about trimming the input. The cmdlet doesn't have a built-in way to trim extra spaces from the input value, which is an arbitrary string. This change: - Adds an example to `Read-Host` showing how user input may need to normalized before it can be used. It also shows how a reader can apply some simple normalizing techniques to clean up the input. - Resolves MicrosoftDocs#10088 - Fixes AB#91532
Prior to this change, the documentation for the `Read-Host` cmdlet didn't include information about trimming the input. The cmdlet doesn't have a built-in way to trim extra spaces from the input value, which is an arbitrary string. This change: - Adds an example to `Read-Host` showing how user input may need to normalized before it can be used. It also shows how a reader can apply some simple normalizing techniques to clean up the input. - Resolves MicrosoftDocs#10088 - Fixes AB#91532
Prior to this change, the documentation for the `Read-Host` cmdlet didn't include information about trimming the input. The cmdlet doesn't have a built-in way to trim extra spaces from the input value, which is an arbitrary string. This change: - Adds an example to `Read-Host` showing how user input may need to normalized before it can be used. It also shows how a reader can apply some simple normalizing techniques to clean up the input. - Resolves #10088 - Fixes AB#91532
Reopening this issue. We still should create an article about string manipulation. |
Created #10289 to track new article |
Prerequisites
Get-Foo
cmdlet" instead of "Typo."Links
https://learn.microsoft.com/en-us/powershell/module/Microsoft.PowerShell.Utility/Read-Host?view=powershell-7.3&viewFallbackFrom=powershell-7
Summary
Typically, any leading or trailing whitespace in user input is considered incidental, and the desire is to remove it.
As an aside: The following feature request asks for a
-Trim
switch to support incidental whitespace removal directly.In the absence of direct trimming support in
Read-Host
(at least for now), showing an example of how to trim after the fact would be helpful; e.g.:Details
No response
Suggested Fix
No response
The text was updated successfully, but these errors were encountered: