Bird
0
0

What is the output of this PowerShell command?

medium📝 Command Output Q4 of 15
PowerShell - Regular Expressions
What is the output of this PowerShell command?
'Hello World' -replace 'World', 'PowerShell'
APowerShell World
BHello World
CHelloWorld
DHello PowerShell
Step-by-Step Solution
Solution:
  1. Step 1: Identify the text to replace

    The pattern 'World' is found in the string 'Hello World'.
  2. Step 2: Replace 'World' with 'PowerShell'

    The -replace operator substitutes 'World' with 'PowerShell', resulting in 'Hello PowerShell'.
  3. Final Answer:

    Hello PowerShell -> Option D
  4. Quick Check:

    Replacement result = Hello PowerShell [OK]
Quick Trick: Text after -replace shows replaced string [OK]
Common Mistakes:
  • Expecting original string unchanged
  • Confusing replacement order
  • Ignoring spaces in output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes