At 07:33 07.11.2002, Salman said: --------------------[snip]-------------------- >ereg("([-d])[rwxst-]{9}.* [0-9]* [a-zA-Z]+ [0-9: ]* (.+)",$dirline,$regs); > >This regular expressions parses the following line: > >drwxrwxrwx 1 owner group 0 Nov 5 23:19 fantasy > >to return: fantasy >(or in general any filename/directory name) > >The above regular expression works fine in every except when the filename is >something like this: > >drwxrwxrwx 1 owner group 0 Nov 5 23:19 6 fantasy --------------------[snip]--------------------
This will get you into trouble anyway if the file name contains whitespaces... try to use a simple "ls" instead. Anyway, assuming the filename doesn't have whitespaces, and since you're ignoring the preceding fields anyway, just look for the last bunch of nonäwhitespaces at the end of line: ereg("([^\s]+)$", $dirline); this should return "fantasy" for both cases you sent. -- >O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php