Title: Match A Word
Slug: match_a_word
Summary: Match A Word
Date: 2016-05-01 12:00
Category: Regex
Tags: Basics
Authors: Chris Albon

Based on: Regular Expressions Cookbook

Preliminaries


In [15]:
# Load regex package
import re

Create some text


In [16]:
# Create a variable containing a text string
text = 'The quick brown fox jumped over the lazy brown bear.'

Apply regex


In [21]:
# Find any word of three letters
re.findall(r'\b...\b', text)


Out[21]:
['The', 'fox', 'the']