8) Regular Expressions
đź“– Lecture
Why should you learn about character string manipulation and working with text data? Well, because a considerable amount of information and data is precisely in the form of text. And sooner or later (I would say sooner than later) you will have to deal with some kind of string manipulation for your data analysis. So it’s better to be prepared for such tasks and know how to perform them inside the R environment.
To unleash the power of string manipulation, we need to take things to the next level and learn about Regular Expressions or regex for short. Namely, regex allows us to describe a certain amount of text called “patterns”. The name “Regular Expression” does not say much. However, regular expressions are all about text.
Regular expression patterns consist of a combination of alphanumeric characters as well as special characters. A regex pattern can be as simple as a single character, or it can be formed by several characters with a more complex structure. In all cases we construct regular expressions much in the same form in which we construct arithmetic expressions, by using various operators to combine smaller expressions.
đź“š Reading
Read chapters 13 and 14 of “R for Strings”:
🔬 Lab
This week you’ll learn how to perform regex operations.
🎯 Objectives
- Being able to describe what a regular expression is
- Explain what a literal character is
- Explain what a metacharacter is
- Give an example of the wildcard metacharacter “.” (dot)
- Give an example of how to escape a metacharacter
- Explain what a character set is
- Explain what a character range is
- Explain what a POSIX character class is
đź”” Assignments
- HW6 due this 03/08
- Shiny App1 released on 03/09, due 03/22