Intro to regular expressions

This tutorial introduces regular expressions through:

  1. Shell wildcards and bracket notation
  2. Pattern searching with grep -E
  3. Regex substitution with sed -E
  4. Brief intro to regex functionality in text editors, e.g. including Vim
  5. Brief intro to regex functions in Python
  6. Brief intro to regex functions in R

Prerequisites

Basic Unix command line familiarity, inc. cd, ls, cat, grep, echo
Basic Vim usage
Basic Python usage
Basic R usage

Participants will need a copy of all files in the data directory of this course’s repository and to be on a bash command line, cd’d to location of files. Data may be obtained through:
https://github.com/csiro-data-school/regex-exercise-data.git

Schedule

Setup Download files required for the lesson
00:00 1. Regular Expressions: The pitch What sort of capabilities do regular expressions provide?
What are regular expressions?
00:10 2. Shell wildcards - a type of regex Are regular expressions available in standard Unix commands?
00:50 3. Pattern matching with grep -E, part 1 How do we write regexs to match complex patterns in files or output streams?
02:20 4. Pattern matching with grep -E, part 2 How do we use predefined character classes for more complex search patterns?
03:20 5. Find... and replace! With sed. How do we find and replace content using regex patterns?
05:20 6. Regexs within text editors How can we invoke regular expressions within certain text editors?
05:25 7. Python regular expressions How can we invoke regular expressions using Python?
05:35 8. R regular expressions How can we invoke regular expressions using R?
05:45 Finish

The actual schedule may vary slightly depending on the topics and exercises chosen by the instructor.