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.
This exercise is part of the course
String Manipulation with stringr in R
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Create vector of characters
characters <- c("Algernon", "Jack", "Lane", "Cecily", "Gwendolen", "Chasuble",
"Merriman", "Lady Bracknell", "Miss Prism")
# Match start, then character name, then .
pattern_3 <- ___
# View matches of pattern_3
___
# View non-matches of pattern_3
___