PowerShell - Regular ExpressionsWhy does the regex pattern '[a-z]+|[0-9]+' match 'abc123' partially in PowerShell?ABecause + quantifier matches zero or more charactersBBecause the alternation operator | matches either letters or digits separatelyCBecause character classes cannot be combinedDBecause PowerShell does not support alternation in regexCheck Answer
Step-by-Step SolutionSolution:Step 1: Understand alternation operator | in regex| means match either the pattern before or after it.Step 2: Analyze pattern '[a-z]+|[0-9]+'This matches one or more letters OR one or more digits, not both together.Final Answer:Alternation causes partial matches of letters or digits separately -> Option BQuick Check:Alternation | matches either pattern separately [OK]Quick Trick: Use | to match alternatives, not combined sequences [OK]Common Mistakes:Thinking | matches combined sequencesConfusing + quantifier meaningBelieving PowerShell lacks alternation support
Master "Regular Expressions" in PowerShell9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More PowerShell Quizzes Error Handling - Throw statement - Quiz 8hard Error Handling - Why error handling prevents script failure - Quiz 13medium File and Directory Operations - Why file management is core to scripting - Quiz 5medium File and Directory Operations - Why file management is core to scripting - Quiz 10hard File and Directory Operations - Test-Path for existence checks - Quiz 7medium File and Directory Operations - Writing files (Set-Content, Out-File) - Quiz 12easy Functions - Pipeline input (ValueFromPipeline) - Quiz 11easy Regular Expressions - Named captures - Quiz 5medium Regular Expressions - Regex with Select-String - Quiz 7medium Working with Objects - Measure-Object for statistics - Quiz 9hard