Does glob() have negation?

前端 未结 5 1768
执念已碎
执念已碎 2020-12-10 13:47

I know I can do this...

glob(\'/dir/somewhere/*.zip\');

...to get all files ending in .zip, but is there a way to return all f

5条回答
  •  伪装坚强ぢ
    2020-12-10 14:08

    This pattern will work:

    glob('/dir/somewhere/*.{?,??,[!z][!i][!p]*}', GLOB_BRACE);
    

    which finds everything in /dir/somewhere/ ending in a dot followed by either

    • one character (?)
    • or two characters (??)
    • or anything not starting with the consecutive letter z,i,p ([!z][!i][!p]*)

提交回复
热议问题