# Match text between two strings with regular expression
clean_text ='before(.*?)after', text).group(1)
import re
s = 'Part 1. Part 2. Part 3 then more text''Part 1\.(.*?)Part 3', s).group(1)
' Part 2. ''Part 1(.*?)Part 3', s).group(1)
'. Part 2. '
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter