Newbie backreference question

Larry Bates lbates at syscononline.com
Thu Jun 30 17:28:20 EDT 2005


a='test string'
print a.split()[:-1]

I'm assuming that you want the last space separated word?

Larry Bates


paulm wrote:
> Hi,
> 	In perl I can do something like:
> 
> $a = 'test string';
> $a =~ /test (\w+)/;
> $b = $1;
> print $b . "\n";
> 
> and my output would be "string".
> 
> 	How might this snippet be written in python?
> 
> Thanks to all...



More information about the Python-list mailing list