Title: Match Exact Text
Slug: match_exact_text
Summary: Match Exact Text
Date: 2016-05-01 12:00
Category: Regex
Tags: Basics
Authors: Chris Albon

Based on: Regular Expressions Cookbook

Preliminaries


In [21]:
# Load regex package
import re

Create some text


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

Apply regex


In [23]:
# Find all instances of the exact match 'The'
re.findall(r'The', text)


Out[23]:
['The']