Session Ready
Exercise

If you don't know what you're looking for

So far you've used str_detect() which returns TRUE if the pattern matches and FALSE otherwise. But regular expressions are also excellent at extracting the searched term from a larger amount of text. You can use the str_match() function for that.

The next special character you'll get to know is the period: ".". The period matches any character, it's like a wild card. So if you search for example for "..." you will find three characters - be it letters or numbers or even white spaces.

This is pretty handy, except if you need to search for an actual full stop ".". In that case: escape the period with two backslashes: "\\."

Instructions
100 XP
  • Match not only Saw 4 but also the other sequels.
  • Match the first four characters of all the movie titles that start with "K".
  • Detect the movie that ends with an actual full stop ".".