Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

find text between two strings regex python

>>> import re
>>> s = 'Part 1. Part 2. Part 3 then more text'
>>> re.search(r'Part 1.(.*?)Part 3', s).group(1)
' Part 2. '
>>> re.search(r'Part 1(.*?)Part 3', s).group(1)
'. Part 2. '
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #find #text #strings #regex #python
ADD COMMENT
Topic
Name
8+7 =