Bird
0
0

Which operator would you use in PowerShell to check if a string matches a regular expression pattern?

easy📝 Conceptual Q2 of 15
PowerShell - Operators
Which operator would you use in PowerShell to check if a string matches a regular expression pattern?
A-match
B-like
C-eq
D-contains
Step-by-Step Solution
Solution:
  1. Step 1: Identify regex matching operator

    The -match operator in PowerShell is designed to check if a string matches a regular expression pattern.
  2. Step 2: Exclude other operators

    -like uses wildcards, -eq checks exact equality, and -contains is for collections, not regex.
  3. Final Answer:

    -match -> Option A
  4. Quick Check:

    -match = regex match [OK]
Quick Trick: Use -match for regex patterns, not -like [OK]
Common Mistakes:
  • Using -like for regex
  • Confusing -eq with pattern matching
  • Using -contains for strings

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes