Match Text Between HTML Tags

Based on: Regular Expressions Cookbook

Preliminaries

# Load regex package
import re

Create some text

# Create a variable containing a text string
text = '<p>The quick brown fox.</p><p>The lazy brown bear.</p>'

Apply regex

# Find any text between '<p>' and '</p>'
re.findall(r'<p>(.*?)</p>', text)
['The quick brown fox.', 'The lazy brown bear.']