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;
import re data = "some input data" m = re.search("some (input) data", data) if m: # "if match was successful" / "if matched" print m.group(1)
Check the docs for more.