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!
==Compared to regular expressions== Globs do not include syntax for the [[Kleene star]] which allows multiple repetitions of the preceding part of the expression; thus they are not considered [[regular expression]]s, which can describe the full set of [[regular language]]s over any given finite alphabet.<ref>{{cite book | last1 = Hopcroft | first1 = John E. | last2 = Motwani | first2 = Rajeev | last3 = Ullman | first3 = Jeffrey D. | title = Introduction to Automata Theory, Languages, and Computation | publisher = Addison-Wesley | year = 2000 | edition = 2nd}}</ref> {| class="wikitable" |- ! Common wildcard ! Equivalent regular expression |- | {{code|?}} | {{code|.}} |- | {{code|*}} | {{code|.*}} |} Globs attempt to match the entire string (for example, {{code|S*.DOC}} matches S.DOC and SA.DOC, but not POST.DOC or SURREY.DOCKS), whereas, depending on implementation details, regular expressions may match a substring. === Implementing as regular expressions === The original Mozilla [[proxy auto-config]] implementation, which provides a glob-matching function on strings, uses a replace-as-RegExp implementation as above. The bracket syntax happens to be covered by regex in such an example. Python's fnmatch uses a more elaborate procedure to transform the pattern into a regular expression.<ref name=py>{{cite web |title=Lib/fnmatch.py |url=https://github.com/python/cpython/blob/3.8/Lib/fnmatch.py |publisher=Python |access-date=10 November 2021 |date=20 January 2021 |archive-date=2021-11-10 |archive-url=https://web.archive.org/web/20211110204645/https://github.com/python/cpython/blob/3.8/Lib/fnmatch.py |url-status=live }}</ref>
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)