in reply to get last matches of the given string
Note that Perl shortcut of \w also includes _0-9 Often this doesn't matter and I just use the \w instead of making a special set.my ($last) = $in =~ m/(\w+)$/i; print "last=$last\n"; my ($second_to_last) = ($in =~ m/(\w+)/gi)[-2]; #[-1] would have been +last print "second to last=$second_to_last\n"; __END__ Prints: last=senthil second to last=foo
|
|---|