Recall & Review
beginner
What does the regex quantifier
* mean?The
* quantifier means "match zero or more occurrences" of the preceding character or group. For example, a* matches '', 'a', 'aa', 'aaa', and so on.Click to reveal answer
beginner
What is the difference between
+ and ? quantifiers in regex?+ means "one or more occurrences" while ? means "zero or one occurrence" of the preceding element. For example, a+ matches 'a', 'aa', 'aaa', but not ''. a? matches '' or 'a'.Click to reveal answer
beginner
What does the anchor
^ do in a regex pattern?The
^ anchor matches the start of a string. For example, ^Hello matches 'Hello world' but not 'Say Hello'.Click to reveal answer
beginner
What does the anchor
$ do in a regex pattern?The
$ anchor matches the end of a string. For example, world$ matches 'Hello world' but not 'world peace'.Click to reveal answer
beginner
In PowerShell, how would you check if a string starts with 'Test' using regex anchors?
You can use the
-match operator with the pattern ^Test. For example: 'Test string' -match '^Test' returns True because the string starts with 'Test'.Click to reveal answer
What does the regex quantifier
? mean?✗ Incorrect
The
? quantifier matches zero or one occurrence of the preceding element.Which regex anchor matches the end of a string?
✗ Incorrect
The
$ anchor matches the end of a string.In PowerShell, which operator is used to test if a string matches a regex pattern?
✗ Incorrect
The
-match operator tests if a string matches a regex pattern.What does the regex quantifier
+ require at minimum?✗ Incorrect
The
+ quantifier requires at least one occurrence of the preceding element.What does the regex pattern
^abc$ match?✗ Incorrect
The pattern
^abc$ matches strings that are exactly 'abc' with nothing before or after.Explain how regex quantifiers
*, +, ? differ and give a simple example for each.Think about how many times the character can appear.
You got /4 concepts.
Describe how anchors
^ and $ help in matching patterns in strings.Anchors fix the position in the string where the match must occur.
You got /3 concepts.