Bird
0
0

Which of the following is the correct PowerShell regex pattern to match exactly three digits at the end of a string?

easy📝 Syntax Q3 of 15
PowerShell - Regular Expressions
Which of the following is the correct PowerShell regex pattern to match exactly three digits at the end of a string?
A\d{3}$
B^\d{3}
C\d{3}^
D^\d{3}$
Step-by-Step Solution
Solution:
  1. Step 1: Understand anchors for string positions

    ^ matches start, $ matches end of string.
  2. Step 2: Match exactly three digits at the end

    Pattern ^\d{3}$ matches exactly three digits at the start and end of the string.
  3. Final Answer:

    ^\d{3}$ -> Option D
  4. Quick Check:

    Pattern ^\d{3}$ = exactly three digits at start and end [OK]
Quick Trick: Use ^ and $ to anchor pattern at string start and end [OK]
Common Mistakes:
  • Using ^ instead of $ for end of string
  • Placing anchors incorrectly
  • Misusing escape sequences

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes