I've said it before and I'll say it again, I'd like Python a lot more if it abandoned re and handled regex like perl did.
$foo =~ /regex/
$result = $foo =~ /regex/
if ($foo =~ /regex/) {whatever;}
while (/regex/) {whatever;}
The captures ($1, $2, etc.) are global and usable wherever you need them.In this particular case the default is that $ matches the end of a string without a newline but you can include it anytime you need to:
$foo =~ /regex$/ # end of string without newline
$foo =~ /regex$/m # end of string with newline