I recently got into a friendly argument with Ghoti about what constitutes a regular expression in the comments to my answer to this question. I claimed that the following is a regular expression:
`[Rr]eading[Tt]est[Dd]ata`
Ghoti disagreed, claiming it is a file glob instead. The glob page on wikipedia claims that (emphasis mine):
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 expressions, which can describe a larger set of regular languages over any given finite alphabet.
However, there is no citation for this claim, indicating that it is just a particular wikipedia editor's opinion.
The The Single UNIX ® Specification, Version 2, states that a Basic Regular Expression (BRE) can even be a single character:
An ordinary character is a BRE that matches itself: any character in the supported character set, except for the BRE special characters listed in BRE Special Characters .
So, what is the definition of a regular expression in the *nix world, and does that definition exclude file globs?
grep
,sed
, andawk
. Vim uses its own variety, as does Perl.*
has two different meanings in BRE and globs. Note: I don't think the term glob is used anywhere in the POSIX spec - it's called Pattern Matching instead and is described in the shell language chapter.