Week 9: Strings and regular expressions
Lectures
- 9.1 stringr: Strings (PDF)
- 9.2 stringr: Regular Expressions (PDF)
- 9.3 stringr: Summary (PDF) function catalog
- 9.4 Regex: The Complete Rules (PDF) symbol catalog
- 9.5 Regex: Groups and Lookaheads (PDF)
- 9.6 Regex: Capturing and Backreferences (PDF)
- 9.7 Regex: Lookaheads and Lookbehinds (PDF)
Labs
- Lab 9: Strings and Regex(PDF)
- Lab 9 solutions (password)
Practice
- stringr: Lookarounds and Pipelines (.qmd) challenges with solutions
Additional readings
- stringr cheat sheet (Posit)
- R for Data Science: Strings
- R for Data Science: Regular expressions
- stringr documentation
- STAT 545: Character vectors
Discussion
- Why is
str_detect()often easier to use in a tidy pipeline thangrepl()? - In words, write a pattern that finds a DC ZIP code. What would that pattern miss?