Get access to all lessons in this course.
-
Welcome to Data Cleaning with R
- What is Data Cleaning?
- Course Logistics and Materials
-
Data Organization
- Data Organization Best Practices
- Tidy Data
- Grouping and Indicator Variables
- NA and Empty Values
- Data Sharing Best Practices
-
Restructuring Data
- Tidyverse Refresher
- Working with Columns with across()
- Pivoting Data
- coalesce() and fill()
-
Regular Expressions
- What are Regular Expressions?
- Understanding and Testing Regular Expressions
- Literal Characters and Metacharacters
- Metacharacters: Quantifiers
- Metacharacters: Alternation, Special Sequences, and Escapes
- Combining Metacharacters
- Regex in R
- Regular Expressions and Data Cleaning, Part 1
- Regular Expressions and Data Cleaning, Part 2
-
Common Issues
- Common Issues in Data Cleaning
- Unusable Variable Names
- Whitespace
- Letter Case
- Missing, Implicit, or Misplaced Grouping Variables
- Compound Values
- Duplicated Values
- Broken Values
- Empty Rows and Columns
- Parsing Numbers
- Putting Everything Together
Data Cleaning with R
Understanding and Testing Regular Expressions
This lesson is locked
This lesson is called Understanding and Testing Regular Expressions, part of the Data Cleaning with R course. This lesson is called Understanding and Testing Regular Expressions, part of the Data Cleaning with R course.
Transcript
Click on the transcript to go to that point in the video. Please note that transcripts are auto generated and may contain minor inaccuracies.
Your Turn
Navigate to rubular, regex101, regexr, or regexpal and familiarize yourself with the user interface.
Input the following text into the test string field:
2 cups whole milk 1 cup white rice (uncooked) 1 pinch salt 1/2 cup water 1/4 cup dark brown sugar
Write regular expressions (one at a time) to match the wet ingredients and look at the match results.
Learn More
In addition to the regex testing websites above, you might be interested in the regexplain
package.
Another approach to doing regex in R is to use the str_view()
function from the stringr
package, which shows you matches in a string.
You need to be signed-in to comment on this post. Login.