PowerShell - Regular ExpressionsWhich of the following is the correct PowerShell syntax to check if the string 'Hello123' contains digits using regex?A'Hello123' -contains '\d+'B'Hello123' -match '[a-z]+'C'Hello123' -match '\d+'D'Hello123' -like '*\d+'Check Answer
Step-by-Step SolutionSolution:Step 1: Identify correct operator and patternPowerShell uses '-match' to test regex patterns. '\d+' matches one or more digits.Step 2: Check options'Hello123' -match '\d+' uses '-match' with '\d+' correctly. Others use wrong operators or patterns.Final Answer:'Hello123' -match '\d+' -> Option CQuick Check:Use '-match' with '\d+' for digits [OK]Quick Trick: Use '-match' with '\d+' to find digits [OK]Common Mistakes:Using '-contains' instead of '-match'Using '-like' with regex patternsForgetting to escape backslash in regex
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