Bird
0
0

What is wrong with this PowerShell regex pattern?

medium📝 Debug Q7 of 15
PowerShell - Regular Expressions
What is wrong with this PowerShell regex pattern?
$pattern = '[a-zA-Z0-9]++'
AMissing escape characters
BCharacter class syntax is incorrect
CThe ++ quantifier is invalid in PowerShell regex
DNo error, pattern is valid
Step-by-Step Solution
Solution:
  1. Step 1: Review the quantifier usage

    ++ is not a valid quantifier in PowerShell regex (uses .NET regex).
  2. Step 2: Confirm character class syntax

    [a-zA-Z0-9] is a valid character class; problem is with ++ quantifier.
  3. Final Answer:

    Invalid ++ quantifier causes error -> Option C
  4. Quick Check:

    Invalid quantifier ++ = Error [OK]
Quick Trick: Avoid ++ quantifier; use + or * instead [OK]
Common Mistakes:
  • Using ++ quantifier
  • Misunderstanding character class syntax
  • Unnecessary escapes inside character class

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes