1. Learn
  2. /
  3. Courses
  4. /
  5. Intermediate Regular Expressions in R

Exercise

Starts with, ends with

You've already seen how you can search for certain characters at the beginning of a string using the caret "^". Of course, regular expressions also offer a way to search for things at the end of a string. This is what the dollar sign "$" will do.

When creating a pattern to look for something at the beginning of a line, use the caret followed by a search term "^___". When looking for something at the end, type the search term first and then append the dollar sign "___$". The order of appearance is very important when creating regular expressions.

Instructions

100 XP
  • Run the first line to have a look at the movie titles you're working with.
  • Create a pattern that lists all the movies that start with "The".
  • Create a pattern that searches movies that end with "3D".