PowerShell - Regular ExpressionsWhy does Select-String with pattern '\bword\b' only match whole words and not substrings?ABecause '\b' matches the start of the line onlyBBecause '\b' matches word boundaries, ensuring exact word matchesCBecause '\b' matches any whitespace characterDBecause '\b' matches digits onlyCheck Answer
Step-by-Step SolutionSolution:Step 1: Understand the meaning of '\b' in regex'\b' matches a word boundary, i.e., position between word and non-word characters.Step 2: Explain effect on matchingUsing '\bword\b' matches 'word' as a whole word, not part of longer words.Final Answer:Because '\b' matches word boundaries, ensuring exact word matches -> Option BQuick Check:\b = word boundary anchor in regex [OK]Quick Trick: Use \b to match whole words only in regex [OK]Common Mistakes:Thinking \b matches whitespace or line startConfusing \b with digit matchingAssuming it matches substrings
Master "Regular Expressions" in PowerShell9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More PowerShell Quizzes Error Handling - Throw statement - Quiz 14medium Error Handling - $Error automatic variable - Quiz 2easy File and Directory Operations - Test-Path for existence checks - Quiz 1easy File and Directory Operations - Reading file content (Get-Content) - Quiz 13medium File and Directory Operations - Get-ChildItem for listing - Quiz 3easy Functions - Parameters - Quiz 6medium Modules and Script Organization - Installing modules (Install-Module) - Quiz 10hard Modules and Script Organization - Module creation basics - Quiz 1easy Modules and Script Organization - Why modules package reusable code - Quiz 10hard Regular Expressions - match operator - Quiz 13medium