Bird
0
0

What does the .Trim() method do to a string in PowerShell?

easy📝 Conceptual Q11 of 15
PowerShell - String Operations
What does the .Trim() method do to a string in PowerShell?
AConverts the string to uppercase
BSplits the string into an array based on a separator
CReplaces a part of the string with another string
DRemoves spaces from the start and end of the string
Step-by-Step Solution
Solution:
  1. Step 1: Understand the purpose of .Trim()

    The .Trim() method removes whitespace characters from the beginning and end of a string.
  2. Step 2: Compare with other methods

    .Split() breaks a string into parts, .Replace() swaps text, and uppercase conversion is unrelated.
  3. Final Answer:

    Removes spaces from the start and end of the string -> Option D
  4. Quick Check:

    .Trim() = Remove spaces [OK]
Quick Trick: Trim cleans spaces only at string edges [OK]
Common Mistakes:
  • Confusing .Trim() with .Split()
  • Thinking .Trim() changes inside spaces
  • Mixing .Trim() with .Replace()

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes