import re as regex s = 'asdf=5;iwantthis123jasd' result = regex.match('asdf=5;(.*)123jasd', s) print(result)