in reply to Match last word in a sentence
$ perl -le' my $list = "This is my list"; $list =~ /(.+)\s(\w+)/; my $last = $2; my $the_rest = $1; print $the_rest; print $last; ' This is my list
$ perl -le' my $list = "This is my list"; ( reverse $list ) =~ /(\w+)\s(.+)/; my $last = reverse $1; my $the_rest = reverse $2; print $the_rest; print $last; ' This is my list
|
|---|