At 07:33 07.11.2002, Salman said:
>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

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

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to