Bird
0
0

What does the -match operator do in PowerShell?

easy📝 Conceptual Q11 of 15
PowerShell - String Operations
What does the -match operator do in PowerShell?
AConverts a string to uppercase
BReplaces text in a string
CSplits a string into an array
DChecks if a string fits a pattern using regular expressions
Step-by-Step Solution
Solution:
  1. Step 1: Understand the purpose of -match

    The -match operator is used to test if a string matches a regular expression pattern.
  2. Step 2: Compare with other string operations

    Replacing text uses -replace, splitting uses -split, and uppercase conversion uses ToUpper(). These are different from -match.
  3. Final Answer:

    Checks if a string fits a pattern using regular expressions -> Option D
  4. Quick Check:

    -match = pattern check [OK]
Quick Trick: Remember: -match means 'does it fit the pattern?' [OK]
Common Mistakes:
  • Confusing -match with -replace or -split
  • Thinking -match changes the string
  • Assuming -match returns the matched text directly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes