suppressPackageStartupMessages(library("tidyverse"))
package 㤼㸱tidyverse㤼㸲 was built under R version 3.6.3
1. How would you match the literal string “\(^\)”?
To check that the pattern works, I’ll include both the string “\(^\)”, and an example where that pattern occurs in the middle of the string which should not be matched.
str_view(c("$^$", "ab$^$sfas"), "^\\$\\^\\$$", match = TRUE)
Registered S3 methods overwritten by 'htmltools':
method from
print.html tools:rstudio
print.shiny.tag tools:rstudio
print.shiny.tag.list tools:rstudio
Registered S3 method overwritten by 'htmlwidgets':
method from
print.htmlwidget tools:rstudio
2. Given the corpus of common words in stringr::words
, create regular expressions that find all words that:
Since this list is long, you might want to use the match argument to str_view()
to show only the matching or non-matching words.
1. The words that start with “y” are:
str_view(stringr::words, "^y", match = TRUE)
2. End with “x”
str_view(stringr::words, "x$", match = TRUE)
3. Are exactly three letters long are
str_view(stringr::words, "^...$", match = TRUE)
4. The words that have seven letters or more are
str_view(stringr::words, ".......", match = TRUE)
LS0tDQp0aXRsZTogIkFuY2hvcnMiDQpvdXRwdXQ6IA0KICBodG1sX25vdGVib29rOg0KICAgIHRvYzogdHJ1ZQ0KICAgIHRvY19mbG9hdDogdHJ1ZQ0KLS0tDQoNCmBgYHtyfQ0Kc3VwcHJlc3NQYWNrYWdlU3RhcnR1cE1lc3NhZ2VzKGxpYnJhcnkoInRpZHl2ZXJzZSIpKQ0KYGBgDQoNCiMjIyAxLiBIb3cgd291bGQgeW91IG1hdGNoIHRoZSBsaXRlcmFsIHN0cmluZyAiJF4kIj8NCg0KVG8gY2hlY2sgdGhhdCB0aGUgcGF0dGVybiB3b3JrcywgSeKAmWxsIGluY2x1ZGUgYm90aCB0aGUgc3RyaW5nICIkXiQiLCBhbmQgYW4gZXhhbXBsZSB3aGVyZSB0aGF0IHBhdHRlcm4gb2NjdXJzIGluIHRoZSBtaWRkbGUgb2YgdGhlIHN0cmluZyB3aGljaCBzaG91bGQgbm90IGJlIG1hdGNoZWQuDQoNCmBgYHtyfQ0Kc3RyX3ZpZXcoYygiJF4k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