Bird
0
0

Why does the regex pattern '[a-z]+|[0-9]+' match 'abc123' partially in PowerShell?

hard📝 Conceptual Q10 of 15
PowerShell - Regular Expressions
Why does the regex pattern '[a-z]+|[0-9]+' match 'abc123' partially in PowerShell?
ABecause + quantifier matches zero or more characters
BBecause the alternation operator | matches either letters or digits separately
CBecause character classes cannot be combined
DBecause PowerShell does not support alternation in regex
Step-by-Step Solution
Solution:
  1. Step 1: Understand alternation operator | in regex

    | means match either the pattern before or after it.
  2. Step 2: Analyze pattern '[a-z]+|[0-9]+'

    This matches one or more letters OR one or more digits, not both together.
  3. Final Answer:

    Alternation causes partial matches of letters or digits separately -> Option B
  4. Quick Check:

    Alternation | matches either pattern separately [OK]
Quick Trick: Use | to match alternatives, not combined sequences [OK]
Common Mistakes:
  • Thinking | matches combined sequences
  • Confusing + quantifier meaning
  • Believing PowerShell lacks alternation support

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes