glob

Search file systems with glob patterns using the D programming language

Version

0.4.0

License

Boost Software License - Version 1.0

  • Declaration

    string[] glob(string path_name);

    Return all the paths that match the glob pattern

    Parameters

    string path_name

    The path with paterns to match.

    Examples

    1. import glob : glob; // Use * to match zero or more instances of a character string[] entries = glob("/usr/bin/python*"); /* entries would contain: /usr/bin/python2 /usr/bin/python2.7 /usr/bin/python3 /usr/bin/python3.5 */ // Use ? to match one instance of a character entries = glob("/usr/bin/python2.?"); /* entries would contain: /usr/bin/python2.6 /usr/bin/python2.7 */ // Use [] to match one instance of a character between the brackets entries = glob("/usr/bin/python[23]"); /* entries would contain: /usr/bin/python2 /usr/bin/python3 */ // Use [!] to match one instance of a character NOT between the brackets entries = glob("/usr/bin/python[!3]"); /* entries would contain: /usr/bin/python2 */ // Use {} to match any of the full strings entries = glob("/usr/bin/{python,ruby}"); /* entries would contain: /usr/bin/python /usr/bin/ruby */

  • Declaration

    string[] globRegex(string path_regex);

    Return all the paths that match the regex pattern

    Parameters

    string path_regex

    The path with regex paterns to match.

    Examples

    1. import glob : globRegex; // Use a regex to match all the number files in /proc/ string[] entries = globRegex(`^/proc/[0-9]*$`); /* entries would contain: /proc/111 /proc/245 /proc/19533 /proc/1 */