Bird
0
0

Why does this command fail?

medium📝 Debug Q7 of 15
PowerShell - Regular Expressions
Why does this command fail?
Select-String -Pattern '\d++' -Path 'data.txt'
AThe backslash must be escaped twice
BThe file 'data.txt' does not exist
CThe pattern should be in single quotes only
D'++' is not a valid quantifier in PowerShell regex
Step-by-Step Solution
Solution:
  1. Step 1: Understand regex quantifiers

    '++' is not a valid quantifier; '+' means one or more, but '++' is invalid syntax.
  2. Step 2: Check other possible issues

    File existence or quoting is not the cause of failure here.
  3. Final Answer:

    '++' is not a valid quantifier in PowerShell regex -> Option D
  4. Quick Check:

    Invalid regex quantifiers cause errors [OK]
Quick Trick: Use valid quantifiers like +, *, ?, {n} in regex [OK]
Common Mistakes:
  • Using invalid quantifiers like '++'
  • Assuming file missing causes regex error
  • Confusing quoting rules

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes