Bird
0
0

Why does the -like operator not support character classes like [a-z] in PowerShell?

hard📝 Conceptual Q10 of 15
PowerShell - Operators
Why does the -like operator not support character classes like [a-z] in PowerShell?
ABecause -like is deprecated in favor of -match
BBecause character classes are only for numeric comparisons
CBecause -like uses simple wildcard matching, not regex
DBecause PowerShell does not support character classes at all
Step-by-Step Solution
Solution:
  1. Step 1: Understand -like operator behavior

    The -like operator uses simple wildcard patterns (* and ?), not regular expressions.
  2. Step 2: Explain character class support

    Character classes like [a-z] are part of regex syntax, supported by -match, not -like.
  3. Final Answer:

    Because -like uses simple wildcard matching, not regex -> Option C
  4. Quick Check:

    -like = wildcards only, no regex [OK]
Quick Trick: Remember -like is simple wildcards, no regex features [OK]
Common Mistakes:
  • Thinking -like supports regex
  • Confusing character classes with wildcards
  • Believing -like is deprecated

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes