PowerShell - Regular ExpressionsWhich PowerShell command correctly checks if the variable $inputString contains any numeric characters using regex?ATest-Path $inputString '\d+'B$inputString -contains '\d+'CSelect-String $inputString '\d+'D$inputString -match '\d+'Check Answer
Step-by-Step SolutionSolution:Step 1: Understand the operatorThe '-match' operator in PowerShell is used to test if a string matches a regex pattern.Step 2: Identify the correct regex pattern'\d+' matches one or more digits.Final Answer:$inputString -match '\d+' -> Option DQuick Check:Using '-contains' or 'Test-Path' does not perform regex matching [OK]Quick Trick: Use '-match' for regex pattern matching in strings [OK]Common Mistakes:Using '-contains' instead of '-match' for regexConfusing cmdlets like Select-String for simple matchingUsing Test-Path which is for filesystem paths
Master "Regular Expressions" in PowerShell9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More PowerShell Quizzes File and Directory Operations - Get-ChildItem for listing - Quiz 1easy File and Directory Operations - CSV operations (Import-Csv, Export-Csv) - Quiz 9hard Functions - Comment-based help - Quiz 10hard Functions - Why functions organize scripts - Quiz 5medium Functions - Comment-based help - Quiz 4medium Functions - Function definition - Quiz 15hard Regular Expressions - Regex with Select-String - Quiz 5medium Regular Expressions - Named captures - Quiz 10hard Regular Expressions - Regex quantifiers and anchors - Quiz 11easy Working with Objects - Object arrays - Quiz 4medium