Bird
0
0

Which of the following is the correct syntax to check if the variable $text contains the word "hello" using the match operator?

easy📝 Syntax Q12 of 15
PowerShell - Regular Expressions
Which of the following is the correct syntax to check if the variable $text contains the word "hello" using the match operator?
A$text -match "hello"
B$text match "hello"
Cmatch $text "hello"
D$text -matches "hello"
Step-by-Step Solution
Solution:
  1. Step 1: Recall correct operator syntax

    The correct operator is -match placed between the variable and the pattern.
  2. Step 2: Identify correct option

    $text -match "hello" uses $text -match "hello", which is the correct syntax. $text -matches "hello" uses -matches which is invalid.
  3. Final Answer:

    $text -match "hello" -> Option A
  4. Quick Check:

    Correct syntax uses -match between variable and pattern [OK]
Quick Trick: Use -match exactly, no plural or missing dash [OK]
Common Mistakes:
  • Using -matches instead of -match
  • Omitting the dash before match
  • Placing match before the variable

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes