3

When I see the term pattern in a description of syntax I infer a regular expression is being specified. Is there a separate term that specifies a wildcard expression?

^foo.*(bar|baz){3} <--  'regular expression' or 'pattern'
foo*bar.txt        <--- 'wildcard expression' or ...?

Or is a wildcard expression just another type of pattern requiring context information to discern the distinction?

  • They're both patterns in my book. This is a bit soft though, terminology as always is person by person when you get to minutia of this detail. – Jimmy Hoffa Jan 24 '14 at 19:03
  • They are both patterns the way that cars and pickup trucks are both vehicles -- same basic concept for very different problems. – Bryan Oakley Jan 24 '14 at 19:17
  • 1
    @JimmyHoffa - I suggest removing closure from this question. Regex pattern and glob pattern are two pattern types which have their exact names. Regex pattern, glob pattern, and wildmat pattern are three most recognized concepts. Therefore, question about pattern name was definitely not opinion-based. It is possible that author of book you refer to didn't do his homework before writing. :) – miroxlav Feb 3 '15 at 12:11
8

The official name is a "glob" pattern. According to Wikipedia, the term originally was the name of a program (/etc/glob) which in the comments called itself "global command". It stems from an early versions of unix.

Wikipedia has a more information, including a link to the original source. The top of the original source contains this comment:

/* global command --

   glob params

   "*" in params matches r.e ".*"
   "?" in params matches r.e. "."
   "[...]" in params matches character class
   "[...a-z...]" in params matches a through z.

   perform command with argument list
  constructed as follows:
     if param does not contain "*", "[", or "?", use it as is
     if it does, find all files in current directory
     which match the param, sort them, and use them

   prepend the command name with "/bin" or "/usr/bin"
   as required.
*/

For more information see http://en.wikipedia.org/wiki/Glob_(programming)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.