in reply to Re: Regular Expression Help
in thread Regular Expression Help

It doesn't work.

Replies are listed 'Best First'.
Re^3: Regular Expression Help
by ptum (Priest) on Nov 18, 2005 at 20:17 UTC
    Fletch is right -- use File::Basename -- but in the more general case of finding the last token in a string, that regex ought to work:
    #!/usr/local/bin/perl use strict; my $string = '/one/two and three/and four / and five'; if ($string =~ /.*\/(.*?)$/) { print "Last token: $1\n"; }
    Or you could always split on your token separator and grab the last element in the resulting array.