I have a list of pathnames in an array such as "C:\dir1\", "C:\dir1\subdir1\", "C:\dir1\subdir1\subdir2\", "C:\dir1\subdir1\subdir2\subdir3\" etc. Now I am interested in getting just "subdir1" from the entire array so I am using a regular expression
where $dir is "dir1" and $2 should give me "subdir1". But with this above all cases match. I just want to get subdir1. What should I use ?
Please help.
Thanks.