Find us on GitHub

Teaching basic lab skills
for research computing

Regular Expressions

A regular expression is a pattern that matches sets of related character strings. While there are patterns that regular expressions cannot match, they are the power tool most programmers turn to when they need to extract information from legacy text files.

  • Regular expressions are written as character strings (which makes the notation somewhat clumsy).
  • Alphanumeric characters match themselves.
  • Use *, +, and ? for repetition.
  • Use character sets, character set shortcuts, and | to match alternatives.
  • Use parentheses to group things and to extract information from matches.
  • Use the regular expression library to find all matches, replace strings, and perform other operations.
  1. Introduction
  2. Operators
  3. Mechanics
  4. Patterns
  5. More Tools