0
0
Bash Scriptingscripting~10 mins

Quantifiers (*, +, ?) in Bash Scripting - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to match zero or more 'a' characters in the string.

Bash Scripting
echo 'aaaab' | grep -E 'a[1]b'
Drag options to blanks, or click blank then click option'
A+
B*
C?
D{2}
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+' which requires at least one 'a'.
Using '?' which matches zero or one 'a' only.
2fill in blank
medium

Complete the code to match one or more digits in the input.

Bash Scripting
echo '12345' | grep -E '[0-9][1]'
Drag options to blanks, or click blank then click option'
A+
B*
C?
D{0,}
Attempts:
3 left
💡 Hint
Common Mistakes
Using '*' which allows zero digits, so it matches empty strings.
Using '?' which matches zero or one digit only.
3fill in blank
hard

Complete the code to match zero or one 'a' followed by 'b'.

Bash Scripting
echo 'ab' | grep -E 'a[1]b'
Drag options to blanks, or click blank then click option'
A?
B*
C+
D{1,2}
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+' which requires at least one 'a'.
Using '*' which allows any number including many 'a's.
4fill in blank
hard

Fill both blanks to match a string starting with one or more 'x' followed by zero or one 'y'.

Bash Scripting
echo 'xxxy' | grep -E '^x[1]y[2]$'
Drag options to blanks, or click blank then click option'
A+
B*
C?
D{2}
Attempts:
3 left
💡 Hint
Common Mistakes
Using '*' for 'x' which allows zero 'x's, but we want at least one.
Using '+' for 'y' which requires at least one 'y'.
5fill in blank
hard

Fill all three blanks to match a string with zero or more 'a's, followed by one or more 'b's, then zero or one 'c'.

Bash Scripting
echo 'aaabbc' | grep -E '^a[1]b[2]c[3]$'
Drag options to blanks, or click blank then click option'
A*
B+
C?
D{3}
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+' for 'a' which requires at least one 'a'.
Using '*' for 'b' which allows zero 'b's but we need at least one.
Using '+' for 'c' which requires at least one 'c'.