Bruno Veldeman wrote:
> 
> I have a string with this format "/blabla/dir/nextdir/name.txt"
> I want only 'name.txt' in one string and the rest in another string.

in this case, i would use split:

$location = "/blabla/dir/nextdir/name.txt";
@dirs = split("\/", $location);

foreach (@dirs) { print "$_\n"; }

will yield:


blabla
dir
nextdir
name.txt

and you can access what you want directly by using:

print $dirs[4];

or, if you don't know how many directories will be in there:

print $dirs[$#dirs];

> Or better, how do I learn to use regex?

i'd recommend Jeffrey Friedl's book, 'Mastering Regular Expressions',
which is available from O'Reilly & Associates.

Reply via email to