Bird
0
0

Which of the following is the correct PowerShell regex pattern to match a string that starts with 'test' and ends immediately after?

easy📝 Syntax Q12 of 15
PowerShell - Regular Expressions
Which of the following is the correct PowerShell regex pattern to match a string that starts with 'test' and ends immediately after?
A^test$
Btest^$
C^test
Dtest$
Step-by-Step Solution
Solution:
  1. Step 1: Understand anchors '^' and '$'

    '^' matches the start of the string, and '$' matches the end of the string.
  2. Step 2: Combine anchors to match exact string

    Using ^test$ ensures the string starts and ends exactly with 'test' and nothing else.
  3. Final Answer:

    ^test$ -> Option A
  4. Quick Check:

    '^' start and '$' end anchors combined [OK]
Quick Trick: Use ^ at start and $ at end for exact match [OK]
Common Mistakes:
  • Placing anchors in wrong order like 'test^$'
  • Using only one anchor and missing full match
  • Confusing anchors with quantifiers

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes