PowerShell - Regular ExpressionsWhich of the following is the correct way to access a named capture group 'year' after a successful match in PowerShell?A$matches{year}B$matches['year']C$matches(year)D$matches.yearCheck Answer
Step-by-Step SolutionSolution:Step 1: Understand $matches variableAfter -match, $matches is a hashtable where keys are group names as strings.Step 2: Access named groupUse $matches['year'] to get the value of the named group 'year'.Final Answer:$matches['year'] -> Option BQuick Check:Access named group = $matches['name'] [OK]Quick Trick: Use square brackets with quotes to access named groups [OK]Common Mistakes:Using dot notation which doesn't work on $matchesUsing parentheses or curly braces incorrectlyForgetting quotes around the group name
Master "Regular Expressions" in PowerShell9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More PowerShell Quizzes Error Handling - Terminating vs non-terminating errors - Quiz 10hard Functions - Default parameter values - Quiz 1easy Functions - Why functions organize scripts - Quiz 2easy Functions - Parameters - Quiz 5medium Functions - Parameter attributes (Mandatory, ValidateSet) - Quiz 10hard Functions - Pipeline input (ValueFromPipeline) - Quiz 8hard Modules and Script Organization - PowerShell Gallery - Quiz 13medium Working with Objects - Group-Object for categorization - Quiz 12easy Working with Objects - Adding methods with ScriptMethod - Quiz 9hard Working with Objects - Why PowerShell is object-oriented - Quiz 6medium