in reply to how to remove everything before last slash in perl?
Another approach, if you really want to use a regex, would be to capture just that part that you're interested in:
my $somestring = "y:/home/lib/directory/piano_book"; ($somestring) = $somestring =~ m#([^/]+)$#; print $somestring; __END__ piano_book
Update: or just to show that always TIMTOWTDI:
my $somestring = "y:/home/lib/directory/piano_book"; my $idx = rindex($somestring, "/"); $somestring = substr($somestring, $idx+1); print $somestring;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how to remove everything before last slash in perl?
by Tux (Canon) on Jun 23, 2012 at 22:58 UTC |