Match A Word

Based on: Regular Expressions Cookbook

Preliminaries

# Load regex package
import re

Create some text

# Create a variable containing a text string
text = 'The quick brown fox jumped over the lazy brown bear.'

Apply regex

# Find any word of three letters
re.findall(r'\b...\b', text)
['The', 'fox', 'the']