1>>> import re
2>>> s = 'Part 1. Part 2. Part 3 then more text'
3>>> re.search(r'Part 1\.(.*?)Part 3', s).group(1)
4' Part 2. '
5>>> re.search(r'Part 1(.*?)Part 3', s).group(1)
6'. Part 2. '
1# You can do this with Reg Exp
2import re
3
4s = 'asdf=5;iwantthis123jasd'
5result = re.search('asdf=5;(.*)123jasd', s)
6print(result.group(1))
1import re as regex
2
3s = 'asdf=5;iwantthis123jasd'
4result = regex.match('asdf=5;(.*)123jasd', s)
5
6print(result)