Bird
0
0

Identify the error in this PowerShell command that tries to check if 'Test123' contains letters:

medium📝 Debug Q14 of 15
PowerShell - Regular Expressions
Identify the error in this PowerShell command that tries to check if 'Test123' contains letters:
'Test123' -match '[A-Z]+'
AThe regex pattern should be '\\d+' to match letters.
BThe '-match' operator is incorrect; should use '-contains'.
CThe string 'Test123' is not quoted properly.
DThe regex pattern only matches uppercase letters, missing lowercase letters.
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the regex pattern

    '[A-Z]+' matches only uppercase letters, but 'Test123' has lowercase 'e', 's', 't'.
  2. Step 2: Identify the error

    Because pattern misses lowercase letters, it won't match 'Test123' correctly.
  3. Final Answer:

    The regex pattern only matches uppercase letters, missing lowercase letters. -> Option D
  4. Quick Check:

    Pattern misses lowercase letters = Error [OK]
Quick Trick: Use [a-zA-Z] to match all letters [OK]
Common Mistakes:
  • Using '-contains' instead of '-match'
  • Ignoring case sensitivity in regex
  • Confusing digits '\\d' with letters

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes