Bird
0
0

Which of the following is the correct syntax to create a named capture group called 'day' matching two digits in PowerShell regex?

easy📝 Syntax Q12 of 15
PowerShell - Regular Expressions
Which of the following is the correct syntax to create a named capture group called 'day' matching two digits in PowerShell regex?
A<code>(day:\d{2})</code>
B<code>(?day:\d{2})</code>
C<code>(?<day>\d{2})</code>
D<code>(?P<day>\d{2})</code>
Step-by-Step Solution
Solution:
  1. Step 1: Recall PowerShell named capture syntax

    PowerShell uses (?pattern) for named captures.
  2. Step 2: Match the correct option

    (?\d{2}) uses (?\d{2}), which is correct syntax for two digits named 'day'.
  3. Final Answer:

    (?\d{2}) -> Option C
  4. Quick Check:

    PowerShell named capture = (?pattern) [OK]
Quick Trick: Use (?pattern) for named groups in PowerShell [OK]
Common Mistakes:
  • Using Python or other language syntax
  • Omitting the question mark
  • Using colon instead of angle brackets

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes