glob

Return all the paths that match the glob pattern

string[]
glob
(
string path_name
)

Parameters

path_name string

The path with paterns to match.

Examples

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
*/

Meta