Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to match any string that starts with 'Hello'.
PowerShell
$pattern = "[1]Hello"
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using $ which anchors to the end of the string.
Using * or + which are quantifiers, not anchors.
✗ Incorrect
The caret ^ is used to anchor the pattern to the start of the string.
2fill in blank
mediumComplete the code to match any string that ends with 'World'.
PowerShell
$pattern = "World[1]"
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using ^ which anchors to the start of the string.
Using quantifiers like + or ? which do not anchor.
✗ Incorrect
The dollar sign $ anchors the pattern to the end of the string.
3fill in blank
hardFix the error in the regex pattern to match one or more digits.
PowerShell
$pattern = "\d[1]"
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using * which means zero or more, allowing empty matches.
Using ? which means zero or one, not enough for multiple digits.
✗ Incorrect
The plus sign + means one or more of the preceding element.
4fill in blank
hardFill both blanks to create a regex that matches exactly three letters at the start of a string.
PowerShell
$pattern = "[1][a-zA-Z][2]"
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using $ which anchors to the end instead of start.
Using + which means one or more, not exactly three.
✗ Incorrect
The caret ^ anchors to the start, and {3} means exactly three repetitions.
5fill in blank
hardFill all three blanks to create a regex that matches a string starting with 'ID' followed by 4 to 6 digits and ending immediately.
PowerShell
$pattern = "[1]ID\d[2][3]"
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using + which means one or more, not a range.
Missing anchors causing partial matches.
✗ Incorrect
^ anchors to start, {4,6} matches 4 to 6 digits, and $ anchors to end.