How can I get part of regex match as a variable in python?

Viewed 58054

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;

I want to do the same in Python and get the text inside the parenthesis in a string like $1.

7 Answers
Related