Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to search for the word 'error' in the file 'log.txt'.
PowerShell
Select-String -Path 'log.txt' -Pattern '[1]'
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using double quotes instead of single quotes.
Searching for a word not present in the file.
✗ Incorrect
The pattern 'error' will match lines containing the word 'error' in the file.
2fill in blank
mediumComplete the code to search for lines that start with 'Error' in 'log.txt'.
PowerShell
Select-String -Path 'log.txt' -Pattern '[1]'
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '$' which matches end of line instead of start.
Not using anchors and matching anywhere in the line.
✗ Incorrect
The regex '^Error' matches lines starting with 'Error'.
3fill in blank
hardFix the error in the code to find lines containing digits in 'data.txt'.
PowerShell
Select-String -Path 'data.txt' -Pattern '[1]'
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using single backslash '\d' which is not escaped properly.
Using character classes that do not match digits.
✗ Incorrect
The pattern '\d+' matches one or more digits. Double backslash is needed to escape in PowerShell strings.
4fill in blank
hardFill both blanks to find lines with exactly 3 letters followed by 2 digits in 'file.txt'.
PowerShell
Select-String -Path 'file.txt' -Pattern '[1][2]'
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up the order of letters and digits.
Using wrong quantifiers for number of characters.
✗ Incorrect
The pattern '^[a-zA-Z]{3}\d{2}$' matches lines starting with 3 letters and ending with 2 digits.
5fill in blank
hardFill all three blanks to find lines containing a word starting with 'a' and ending with 'z' in 'text.txt'.
PowerShell
Select-String -Path 'text.txt' -Pattern '[1][2][3]'
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not using word boundaries '\b'.
Using '+' instead of '*' causing no match for empty middle.
✗ Incorrect
The pattern '\ba.*z\b' matches words starting with 'a' and ending with 'z'. '\b' marks word boundaries.