Regular Expressions for Text Preprocessing

Learn about metacharacters, quantifiers, shorthand character classes, escape sequences, and character classes.

Introduction

There are many elements of regular expressions that we can use. We’ll look at some basic and the most common ones in this lesson and then cover the rarer, more advanced ones later.

Character classes

A character class is a way of defining a group of characters that can match any one character from a given set. We use character classes in regex when we want to match a single character that can be any one of a specific set of characters instead of writing out all the possible characters that can be matched. To define a character class, we enclose a set of characters within square brackets [].

Get hands-on with 1200+ tech skills courses.