Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Glob (programming)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Other implementations== Beyond their uses in shells, globs patterns also find use in a variety of programming languages, mainly to process human input. A glob-style interface for returning files or an fnmatch-style interface for matching strings are found in the following programming languages: * [[C (programming language)|C]] and [[C++]] do not have built-in support for glob patterns in the ISO-defined standard libraries, however on Unix-like systems C and C++ may include <code><glob.h></code> from the [[C POSIX library]] to use <code>glob()</code>. ** C++ itself does not have direct support for glob patterns, however they may be approximated using the <code><filesystem></code> and <code><regex></code> headers, using <code>std::filesystem::directory_iterator()</code> and <code>std::regex_match()</code>. * [[C Sharp (programming language)|C#]] has multiple libraries available through [[NuGet]] such as <code>Glob</code><ref name="dotnet-glob"/> or <code>DotNet.Glob</code>.<ref name="dotnet.glob"/> * [[D (programming language)|D]] has a <code>globMatch</code> function in the <code>std.path</code> module.<ref name="dlang"/> * [[JavaScript]] has a library called <code>minimatch</code> which is used internally by [[Npm (software)|npm]], and <code>micromatch</code>, a purportedly more optimized, accurate and safer globbing implementation used by [[Babel (compiler)|Babel]] and yarn.<ref name="minimatch"/><ref name="micromatch"/> * [[Go (programming language)|Go]] has a <code>Glob</code> function in the <code>filepath</code> package.<ref name="golang"/> * [[Java (programming language)|Java]] has a <code>Files</code> class in the package <code>java.nio.file</code>, containing methods that can operate on glob patterns.<ref name="java"/> * [[Haskell (programming language)|Haskell]] has a <code>Glob</code> package with the main module <code>System.FilePath.Glob</code>. The pattern syntax is based on a subset of [[Zsh]]'s. It tries to optimize the given pattern and should be noticeably faster than a naïve character-by-character matcher.<ref name="hs"/> * [[Perl]] has both a <code>glob</code> function (as discussed in [[Larry Wall]]'s book ''[[Programming Perl]]'') and a ''Glob'' extension which mimics the BSD glob routine.<ref name="pl"/> Perl's angle brackets can be used to glob as well: <code><*.log></code>. * [[PHP]] has a <code>glob</code> function.<ref name="php"/> * [[Python (programming language)|Python]] has a <code>glob</code> module in the standard library which performs wildcard pattern matching on filenames,<ref name="pyglob"/> and an <code>fnmatch</code> module with functions for matching strings or filtering lists based on these same wildcard patterns.<ref name=py/> [[Guido van Rossum]], author of the Python programming language, wrote and contributed a <code>glob</code> routine to [[Berkeley Software Distribution|BSD]] [[Unix]] in 1986.<ref name="isc-glob"/> There were previous implementations of <code>glob</code>, e.g., in the [[ex (text editor)|ex]] and [[File Transfer Protocol|ftp]] programs in previous releases of BSD. * [[Ruby (programming language)|Ruby]] has a <code>glob</code> method for the <code>Dir</code> class which performs wildcard pattern matching on filenames.<ref name="rbdir"/> Several libraries such as Rant and Rake provide a <code>FileList</code> class which has a glob method or use the method <code>FileList.[]</code> identically. * [[Rust (programming language)|Rust]] has multiple libraries that can match glob patterns,<ref>{{cite web|title=#glob - Lib.rs|url=https://lib.rs/keywords/glob|access-date=12 November 2021|website=lib.rs|archive-date=2021-11-12 |archive-url=https://web.archive.org/web/20211112115505/https://lib.rs/keywords/glob|url-status=live}}</ref> the most popular of these being the <code>glob</code> crate.<ref>{{cite web|title=glob - Lib.rs|url=https://lib.rs/crates/glob|access-date=17 January 2025|website=lib.rs}}</ref> * [[SQLite]] has a <code>GLOB</code> function. * [[Tcl]] contains a globbing facility.<ref name="tcl"/>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)