I built a simple code which parses all music folders inside several disks and put the list into an array.

The folders names begin with multiple spaces when they are categories, with a single space when they are "final folders". E.g. see this structure:

```
[0] => /Volumes/SAMPLES/  VOCALS/
[1] => /Volumes/SAMPLES/  VOCALS/  AFRICA/
[2] => /Volumes/SAMPLES/  VOCALS/ AcmeInc Club Vocals/
[3] => /Volumes/SAMPLES/  VOCALS/ AtomicInc Dance Vocals/
[4] => /Volumes/SAMPLES/  VOCALS/  AFRICA/ AfroInc Zulu Vocals/
[5] => /Volumes/SAMPLES/  VOCALS/  AFRICA/ SampleInc Warriors/
[6] => /Volumes/SAMPLES/  VOCALS/  AFRICA/ SampleInc Warriors/SampleInc_Warriors_Ululation/
[7] => /Volumes/SAMPLES/  VOCALS/  AFRICA/ SampleInc Warriors/SampleInc_Warriors_Drums/

```

and so on... I need to select the final folders only and tried several combinations of greedy and non greedy patterns, starting from the final $
E.g. the following path doesn't work:

```
$pattern = "#\/ ([:alnum:]+?)/$#i";
$matches  = preg_grep ($pattern, $root);

```

The expected result should have been:

```
[3] => /Volumes/SAMPLES/  VOCALS/ AcmeInc Club Vocals/
[4] => /Volumes/SAMPLES/  VOCALS/ AtomicInc Dance Vocals/
[5] => /Volumes/SAMPLES/  VOCALS/  AFRICA/ AfroInc Zulu Vocals/
[6] => /Volumes/SAMPLES/  VOCALS/  AFRICA/ SampleInc Warriors/

```

Instead I get all the folders or none or orphans. Please consider that special chars like &or ! could be in the folder name. Thank you for the suggestions, 3 days,tried everything, desperate, thanks!