Bird
0
0

Which PowerShell operator uses regex to test if a string matches a pattern?

easy📝 Conceptual Q2 of 15
PowerShell - Regular Expressions
Which PowerShell operator uses regex to test if a string matches a pattern?
A-contains
B-eq
C-match
D-like
Step-by-Step Solution
Solution:
  1. Step 1: Identify regex operator in PowerShell

    The '-match' operator tests if a string matches a regex pattern.
  2. Step 2: Eliminate other operators

    '-contains' checks collection membership, '-eq' is exact equality, '-like' uses wildcards, not regex.
  3. Final Answer:

    -match -> Option C
  4. Quick Check:

    Regex operator = -match [OK]
Quick Trick: Use -match to check regex pattern matches in strings [OK]
Common Mistakes:
  • Using -like instead of -match for regex
  • Confusing -eq with pattern matching
  • Using -contains for string pattern tests

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes