Hello vijesh,
McA is correct, when dealing with filenames and paths a dedicated module will provide a safer and more portable solution than a hand-written regex. But if you still want to use a regex, try this:
17:12 >perl -wE "my $s = q{/fold1/fold2/fold3/file.pl}; print $1, qq{\ +n} if $s =~ m{^(.+?)[^/]+$}; /fold1/fold2/fold3/ 17:16 >
This works because the second quantifier is greedy but the first is not.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
In reply to Re: regex help
by Athanasius
in thread regex help
by vijesh
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |