Exercise

Identifying the lines, take 2

The pattern "starts with a capital letter, has some other characters then a full stop" wasn't specific enough. You ended up matching lines that started with things like University., July., London., and you missed characters like Lady Bracknell and Miss Prism.

Let's take a different approach. You know the characters names from the play introduction. So, try specifically looking for lines that start with their names. You'll find the or1() function from the rebus package helpful. It specifies alternatives but rather than each alternative being an argument like in or(), you can pass in a vector of alternatives.

We've created the characters vector for you with all the characters names.

Instructions 1/2

undefined XP
    1
    2
  • Create a pattern that matches the start of the string, followed by one of the characters names using or1(), followed by a ..
  • Test your pattern.
    • View matches of pattern_3 on the play_lines character vector.
    • View non-matches of the same.
    • Does it look like it worked?