v Match Any Of A Series Of Options - Regex

Match Any Of A Series Of Options

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 of fox, snake, or bear
re.findall(r'fox|snake|bear', text)
['fox', 'bear']