start = 'asdf=5;' end = '123jasd' s = 'asdf=5;iwantthis123jasd' print s[s.find(start)+len(start):s.rfind(end)]