In Perl it is possible to do something like this (I hope the syntax is right...):
$string =~ m/lalala(I want this part)lalala/; $whatIWant = $1;
See: Python regex match objects
>>> import re >>> p = re.compile("lalala(I want this part)lalala") >>> p.match("lalalaI want this partlalala").group(1) 'I want this part'